bug #18840 [Yaml] properly handle unindented collections (xabbuh)
This PR was merged into the 2.3 branch.
Discussion
----------
[Yaml] properly handle unindented collections
| Q | A
| ------------- | ---
| Branch? | 2.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #8077
| License | MIT
| Doc PR |
Commits
-------
717e1a9
[Yaml] properly handle unindented collections
This commit is contained in:
commit
7830fa7dbd
@ -725,7 +725,7 @@ class Parser
|
||||
*/
|
||||
private function isStringUnIndentedCollectionItem()
|
||||
{
|
||||
return 0 === strpos($this->currentLine, '- ');
|
||||
return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -557,6 +557,34 @@ EOF
|
||||
);
|
||||
}
|
||||
|
||||
public function testSequenceInMappingStartedBySingleDashLine()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
a:
|
||||
-
|
||||
b:
|
||||
-
|
||||
bar: baz
|
||||
- foo
|
||||
d: e
|
||||
EOT;
|
||||
$expected = array(
|
||||
'a' => array(
|
||||
array(
|
||||
'b' => array(
|
||||
array(
|
||||
'bar' => 'baz',
|
||||
),
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
),
|
||||
'd' => 'e',
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user