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', + ], + << [