do not eagerly filter comment lines
Trying to be clever by filtering commented lines inside `getNextEmbedBlock()` does not work as expected. The `#` may as well be part of a multi-line quoted string where it must not be treated as the beginning of a comment. Thus, we only must ensure that a comment-like line does not skip the process of getting the next line of the embed block.
This commit is contained in:
parent
61e1f5705e
commit
d594038ad9
@ -601,21 +601,10 @@ class Parser
|
||||
continue;
|
||||
}
|
||||
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||
// remember ignored comment lines (they are used later in nested
|
||||
// parser calls to determine real line numbers)
|
||||
//
|
||||
// CAUTION: beware to not populate the global property here as it
|
||||
// will otherwise influence the getRealCurrentLineNb() call here
|
||||
// for consecutive comment lines and subsequent embedded blocks
|
||||
$this->locallySkippedLineNumbers[] = $this->getRealCurrentLineNb();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($indent >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
} elseif ($this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} elseif (0 == $indent) {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
|
@ -1554,6 +1554,24 @@ YAML;
|
||||
$this->assertSame(array('foobar' => 'foobar'), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testCommentCharactersInMultiLineQuotedStrings()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
foobar: 'foo
|
||||
#bar'
|
||||
bar: baz
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'foobar' => 'foo #bar',
|
||||
'bar' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testParseMultiLineUnquotedString()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
|
Reference in New Issue
Block a user