Skip to content

Commit

Permalink
fix(yml): fix comment in milti line value
Browse files Browse the repository at this point in the history
  • Loading branch information
soufianZantar committed Jul 26, 2019
1 parent 61b0f79 commit 61130c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Expand Up @@ -2152,6 +2152,17 @@ public function indentedMappingData()

return $tests;
}

public function testMultiLineComment() {
$yaml = <<<YAML
parameters:
abc
# Comment
YAML;

$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
}
}

class B
Expand Down

0 comments on commit 61130c4

Please sign in to comment.