This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #13334).
Discussion
----------
[Yaml] Fixed #10597: Improved Yaml directive parsing
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10597
| License | MIT
| Doc PR | N/A
There was a problem with the regular expression used to process the YAML directive. The modifier `s` made the regex too greedy, replacing everything but the last line of the YAML. Existing tests using the YAML directive contained only one line, that's why they were passing.
Commits
-------
95d8ce3
[Yaml] Fixed #10597: Improved Yaml directive parsing
This commit is contained in:
commit
425385400d
@ -586,7 +586,7 @@ class Parser
|
|||||||
|
|
||||||
// strip YAML header
|
// strip YAML header
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);
|
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#u', '', $value, -1, $count);
|
||||||
$this->offset += $count;
|
$this->offset += $count;
|
||||||
|
|
||||||
// remove leading comments
|
// remove leading comments
|
||||||
|
@ -650,6 +650,17 @@ map_in_map: { foo: { bar: *var } }
|
|||||||
EOF
|
EOF
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testYamlDirective()
|
||||||
|
{
|
||||||
|
$yaml = <<<EOF
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
foo: 1
|
||||||
|
bar: 2
|
||||||
|
EOF;
|
||||||
|
$this->assertEquals(array('foo' => 1, 'bar' => 2), $this->parser->parse($yaml));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class B
|
class B
|
||||||
|
Reference in New Issue
Block a user