[Yaml Parser] fixed Parser to skip comments when inlining sequences
This commit is contained in:
parent
6c2a1c9a57
commit
b5316ebebb
@ -1244,7 +1244,13 @@ class Parser
|
||||
for ($i = 1; isset($this->currentLine[$i]) && ']' !== $this->currentLine[$i]; ++$i) {
|
||||
}
|
||||
|
||||
$value .= trim($this->currentLine);
|
||||
$trimmedValue = trim($this->currentLine);
|
||||
|
||||
if ('' !== $trimmedValue && '#' === $trimmedValue[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value .= $trimmedValue;
|
||||
|
||||
if (isset($this->currentLine[$i]) && ']' === $this->currentLine[$i]) {
|
||||
break;
|
||||
|
@ -1898,6 +1898,30 @@ YAML
|
||||
[new TaggedValue('foo', 'bar')],
|
||||
'[ !foo bar ]',
|
||||
],
|
||||
'with-comments' => [
|
||||
[
|
||||
[new TaggedValue('foo', ['foo', 'baz'])],
|
||||
],
|
||||
<<<YAML
|
||||
- [!foo [
|
||||
foo,
|
||||
baz
|
||||
#bar
|
||||
]]
|
||||
YAML
|
||||
],
|
||||
'with-comments-trailing-comma' => [
|
||||
[
|
||||
[new TaggedValue('foo', ['foo', 'baz'])],
|
||||
],
|
||||
<<<YAML
|
||||
- [!foo [
|
||||
foo,
|
||||
baz,
|
||||
#bar
|
||||
]]
|
||||
YAML
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user