8000 [Component] [Yaml] [Parser] : can parse with trailing space as 2.8 · symfony/symfony@f4f5b99 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f4f5b99

Browse files
committed
[Component] [Yaml] [Parser] : can parse with trailing space as 2.8
1 parent 329b181 commit f4f5b99

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function parse($value, $flags = 0)
175175
$this->refs[$isRef] = end($data);
176176
}
177177
} elseif (
178-
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u', $this->currentLine, $values)
178+
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
179179
&& (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))
180180
) {
181181
if ($context && 'sequence' == $context) {

src/Symfony/Component/Yaml/Tests/ParserTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,20 @@ public function testObjectsSupportDisabledWithExceptions($yaml)
602602
$this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
603603
}
604604

605+
public function testCanParseContentWithTrailingSpaces()
606+
{
607+
$yaml = <<<YAML
608+
items:
609+
foo: bar
610+
YAML;
611+
612+
$expected = [
613+
'items' => ['foo' => 'bar'],
614+
];
615+
616+
$this->assertEquals($expected, $this->parser->parse($yaml));
617+
}
618+
605619
/**
606620
* @group legacy
607621
* @dataProvider invalidDumpedObjectProvider

0 commit comments

Comments
 (0)
0