8000 bug #21084 [Yaml] handle empty lines inside unindented collection (xa… · symfony/symfony@942e0c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 942e0c1

Browse files
committed
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 ------- bbfe6f7 handle empty lines inside unindented collection
2 parents 5ad1586 + bbfe6f7 commit 942e0c1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
423423

424424
$previousLineIndentation = $indent;
425425

426-
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
426+
if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
427427
$this->moveToPreviousLine();
428428
break;
429429
}

src/Symfony/Component/Yaml/Tests/ParserTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ public function getBlockChompingTests()
189189
);
190190
$tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
191191

192+
$yaml = <<<'EOF'
193+
foo:
194+
- bar: |
195+
one
196+
197+
two
198+
EOF;
199+
$expected = array(
200+
'foo' => array(
201+
array(
202+
'bar' => "one\n\ntwo",
203+
),
204+
),
205+
);
206+
$tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml);
207+
192208
$yaml = <<<'EOF'
193209
foo: |
194210
one

0 commit comments

Comments
 (0)
0