diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 7d6112e3b9..c4313f3421 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -751,7 +751,8 @@ class Parser $lines[] = trim($this->currentLine); // quoted string values end with a line that is terminated with the quotation character - if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) { + $escapedLine = str_replace(['\\\\', '\\"'], '', $this->currentLine); + if ('' !== $escapedLine && substr($escapedLine, -1) === $quotation) { break; } } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index dc7c122d59..d2934b5d2b 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1650,6 +1650,33 @@ YAML; $this->assertSame($expected, $this->parser->parse($yaml)); } + public function testEscapedQuoteInQuotedMultiLineString() + { + $yaml = << 'foo "bar" baz', + ]; + + $this->assertSame($expected, $this->parser->parse($yaml)); + } + + public function testBackslashInQuotedMultiLineString() + { + $yaml = << 'foo bar\\', + ]; + + $this->assertSame($expected, $this->parser->parse($yaml)); + } + public function testParseMultiLineUnquotedString() { $yaml = <<