From dccac0ba0af0188ec100e755f915ed1fa0510590 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 6 Jan 2025 23:32:34 +0000 Subject: [PATCH] [Yaml] fix inline notation with inline comment --- src/Symfony/Component/Yaml/Parser.php | 2 +- src/Symfony/Component/Yaml/Tests/ParserTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 2f8afc298ae5f..dadf7df446bcb 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1206,7 +1206,7 @@ private function lexInlineStructure(int &$cursor, string $closingTag, bool $cons $value .= $this->currentLine[$cursor]; ++$cursor; - if ($consumeUntilEol && isset($this->currentLine[$cursor]) && (strspn($this->currentLine, ' ', $cursor) + $cursor) < strlen($this->currentLine)) { + if ($consumeUntilEol && isset($this->currentLine[$cursor]) && ($whitespaces = strspn($this->currentLine, ' ', $cursor) + $cursor) < strlen($this->currentLine) && '#' !== $this->currentLine[$whitespaces]) { throw new ParseException(sprintf('Unexpected token "%s".', trim(substr($this->currentLine, $cursor)))); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0c5c8222b00b0..7725ac8d4d61c 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2160,6 +2160,19 @@ public static function inlineNotationSpanningMultipleLinesProvider(): array << [ + [ + 'map' => [ + 'key' => 'value', + 'a' => 'b', + ], + 'param' => 'some', + ], + << [