Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2dd081a

Browse files
committed
fix(yml): fix comment in milti line value
1 parent 61b0f79 commit 2dd081a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ private function doParse(string $value, int $flags)
386386
$value = '';
387387

388388
foreach ($this->lines as $line) {
389+
if ('' !== $line && '#' === ltrim($line)[0]) {
390+
continue;
391+
}
389392
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
390393
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
391394
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,18 @@ public function indentedMappingData()
21522152

21532153
return $tests;
21542154
}
2155+
2156+
public function testMultiLineComment()
2157+
{
2158+
$yaml = <<<YAML
2159+
parameters:
2160+
abc
2161+
2162+
# Comment
2163+
YAML;
2164+
2165+
$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
2166+
}
21552167
}
21562168

21572169
class B

0 commit comments

Comments
 (0)