From 2e99caacafd20ad433f724ad3ff907e8ecd734dd Mon Sep 17 00:00:00 2001 From: Gocha Ossinkine Date: Thu, 7 May 2020 22:31:15 +0500 Subject: [PATCH] [Yaml] Fix escaped quotes in quoted multi-line string --- src/Symfony/Component/Yaml/Parser.php | 3 ++- .../Component/Yaml/Tests/ParserTest.php | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 7d6112e3b9c6f..c4313f3421ed6 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -751,7 +751,8 @@ private function parseValue($value, $flags, $context) $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 dc7c122d592c2..d2934b5d2b76f 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1650,6 +1650,33 @@ public function testBlankLinesInQuotedMultiLineString() $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 = << pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy