From 61130c471a7ce330c6767b9aea86e5c3dfb33c08 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 | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 4519edb840c7b..88447ebe74af9 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -386,6 +386,9 @@ private function doParse(string $value, int $flags) $value = ''; foreach ($this->lines as $line) { + if ('' !== $line && '#' === $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 6fc02e1d1f105..1e99a59d72b91 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2152,6 +2152,17 @@ public function indentedMappingData() return $tests; } + + public function testMultiLineComment() { + $yaml = <<assertSame(['parameters' => 'abc'], $this->parser->parse($yaml)); + } } class B