8000 [Yaml] fix lexing inline sequences/mappings with trailing whitespaces by xabbuh · Pull Request #39241 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] fix lexing inline sequences/mappings with trailing whitespaces #39241

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 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix lexing inline sequences/mappings with trailing whitespaces
  • Loading branch information
xabbuh committed Nov 30, 2020
commit 66bc898f611efad4a64f7f938c678cc1a0abe4ed
4 changes: 2 additions & 2 deletions src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,11 @@ private function parseValue(string $value, int $flags, string $context)

try {
if ('' !== $value && '{' === $value[0]) {
$cursor = \strlen($this->currentLine) - \strlen($value);
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));

return Inline::parse($this->lexInlineMapping($cursor), $flags, $this->refs);
} elseif ('' !== $value && '[' === $value[0]) {
$cursor = \strlen($this->currentLine) - \strlen($value);
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));

return Inline::parse($this->lexInlineSequence($cursor), $flags, $this->refs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ public function testMultipleWhitespaceAtEndOfLine()
$this->parser->parse($yaml)
);

$yaml = "\nfoo:\n bar: {}\n";
$yaml = "\nfoo:\n bar: {} \n";
$this->assertSame(
[
'foo' => [
Expand Down
0