fix lexing mapping values with trailing whitespaces
This commit is contained in:
parent
27127a4bab
commit
5e455f321a
@ -753,10 +753,10 @@ class Parser
|
|||||||
switch ($value[0] ?? '') {
|
switch ($value[0] ?? '') {
|
||||||
case '"':
|
case '"':
|
||||||
case "'":
|
case "'":
|
||||||
$cursor = \strlen($this->currentLine) - \strlen($value);
|
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));
|
||||||
$parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
|
$parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
|
||||||
|
|
||||||
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*#.*$/A', '', substr($this->currentLine, $cursor))) {
|
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*(#.*)?$/A', '', substr($this->currentLine, $cursor))) {
|
||||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
|
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2671,7 +2671,7 @@ YAML;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMultipleWhitespaceAtEndOfLine()
|
public function testWhitespaceAtEndOfLine()
|
||||||
{
|
{
|
||||||
$yaml = "\nfoo:\n arguments: [ '@bar' ] \n";
|
$yaml = "\nfoo:\n arguments: [ '@bar' ] \n";
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
@ -2692,6 +2692,14 @@ YAML;
|
|||||||
],
|
],
|
||||||
$this->parser->parse($yaml)
|
$this->parser->parse($yaml)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
[
|
||||||
|
'foo' => 'bar',
|
||||||
|
'foobar' => 'baz',
|
||||||
|
],
|
||||||
|
$this->parser->parse("foo: 'bar' \nfoobar: baz")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user