10000 [Component] [Yaml] [Parser] : can parse with trailing space as 2.8 by jsamouh · Pull Request #22216 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Component] [Yaml] [Parser] : can parse with trailing space as 2.8 #22216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Component] [Yaml] [Parser] : can parse with trailing space as 2.8
  • Loading branch information
jsamouh committed Mar 30, 2017
commit ce3d5ab7d109258c0e10853dd87037a8a2fdd93c
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function parse($value, $flags = 0)
$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) {
Expand Down
11 changes: 11 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,17 @@ public function testObjectsSupportDisabledWithExceptions($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
Expand Down
0