bug #21084 [Yaml] handle empty lines inside unindented collection (xabbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[Yaml] handle empty lines inside unindented collection

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21005
| License       | MIT
| Doc PR        |

Commits
-------

bbfe6f73b5 handle empty lines inside unindented collection
This commit is contained in:
Fabien Potencier 2017-01-03 05:44:39 -08:00
commit 942e0c1706
2 changed files with 17 additions and 1 deletions

View File

@ -423,7 +423,7 @@ class Parser
$previousLineIndentation = $indent;
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
$this->moveToPreviousLine();
break;
}

View File

@ -189,6 +189,22 @@ EOF;
);
$tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo:
- bar: |
one
two
EOF;
$expected = array(
'foo' => array(
array(
'bar' => "one\n\ntwo",
),
),
);
$tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |
one