Skip to content

Commit 3065764

Browse files
committed
Fixes #22967
1 parent 0a695a7 commit 3065764

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private function doParse($value, $flags)
421421
}
422422

423423
// try to parse the value as a multi-line string as a last resort
424-
if (0 === $this->currentLineNb && !$this->isNextLineIndented()) {
424+
if (0 === $this->currentLineNb && (!$this->isCurrentLineBlank() || !$this->isCurrentLineLastLineInDocument()) && !$this->isNextLineIndented()) {
425425
$previousLineWasNewline = false;
426426
$previousLineWasTerminatedWithBackslash = false;
427427
$value = '';

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,20 @@ public function testMultiLineStringLastResortParsingOnlyAffectSameIndentationLev
824824
$this->parser->parse($yaml);
825825
}
826826

827+
/**
828+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
829+
*/
830+
public function testMultiLineStringLastResortParsingOnlyAffectMultilineStrings()
831+
{
832+
$yaml = <<<'EOT'
833+
& * ! | > ' " % @ ` #, { asd a;sdasd }-@^qw3
834+
835+
# comment
836+
837+
EOT;
838+
$this->parser->parse($yaml);
839+
}
840+
827841
public function testMultiLineStringLastResortParsing()
828842
{
829843
$yaml = <<<'EOT'

0 commit comments

Comments
 (0)