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 authored and xabbuh committed Jul 29, 2019
1 parent aefc7f5 commit 2af45b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -436,6 +436,9 @@ private function doParse($value, $flags)
$value = '';

foreach ($this->lines as $line) {
if ('' !== $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);
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Expand Up @@ -2292,6 +2292,18 @@ 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 2af45b9

Please sign in to comment.