From dd945e375c5c1e95e1dcbc8d423568ca595e019b Mon Sep 17 00:00:00 2001 From: Soufian EZ ZANTAR Date: Sat, 27 Jul 2019 00:20:27 +0200 Subject: [PATCH] fix(yml): fix comment in milti line value --- src/Symfony/Component/Yaml/Parser.php | 3 +++ src/Symfony/Component/Yaml/Tests/ParserTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index cc094085c62b..4f5c30e16836 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -436,6 +436,9 @@ private function doParse($value, $flags) $value = ''; foreach ($this->lines as $line) { + if ('' !== ltrim($line) && '#' === ltrim($line)[0]) { + continue; + } // If the indentation is not consistent at offset 0, it is to be considered as a ParseError if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0f25732ab442..4b5073fb4ede 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2292,6 +2292,18 @@ public function indentedMappingData() return $tests; } + + public function testMultiLineComment() + { + $yaml = <<assertSame(['parameters' => 'abc'], $this->parser->parse($yaml)); + } } class B