[Component] [Yaml] [Parser] : can parse with trailing space as 2.8
This commit is contained in:
parent
329b1819f1
commit
ce3d5ab7d1
@ -175,7 +175,7 @@ class Parser
|
||||
$this->refs[$isRef] = end($data);
|
||||
}
|
||||
} elseif (
|
||||
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u', $this->currentLine, $values)
|
||||
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
&& (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))
|
||||
) {
|
||||
if ($context && 'sequence' == $context) {
|
||||
|
@ -602,6 +602,17 @@ YAML;
|
||||
$this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
public function testCanParseContentWithTrailingSpaces()
|
||||
{
|
||||
$yaml = "items: \n foo: bar";
|
||||
|
||||
$expected = array(
|
||||
'items' => array('foo' => 'bar'),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider invalidDumpedObjectProvider
|
||||
|
Reference in New Issue
Block a user