From 66bc898f611efad4a64f7f938c678cc1a0abe4ed Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 30 Nov 2020 13:47:21 +0100 Subject: [PATCH] fix lexing inline sequences/mappings with trailing whitespaces --- src/Symfony/Component/Yaml/Parser.php | 4 ++-- src/Symfony/Component/Yaml/Tests/ParserTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 0c4a76e2b1..56322c387d 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -741,11 +741,11 @@ class Parser 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); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 3f228a4576..cea3d3f330 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2683,7 +2683,7 @@ YAML; $this->parser->parse($yaml) ); - $yaml = "\nfoo:\n bar: {}\n"; + $yaml = "\nfoo:\n bar: {} \n"; $this->assertSame( [ 'foo' => [