diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 2f8afc298ae5f..fc431f4f789d6 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1207,7 +1207,10 @@ private function lexInlineStructure(int &$cursor, string $closingTag, bool $cons ++$cursor; if ($consumeUntilEol && isset($this->currentLine[$cursor]) && (strspn($this->currentLine, ' ', $cursor) + $cursor) < strlen($this->currentLine)) { - throw new ParseException(sprintf('Unexpected token "%s".', trim(substr($this->currentLine, $cursor)))); + $remain = trim(substr($this->currentLine, $cursor)); + if (!str_starts_with($remain, '#')) { + throw new ParseException(sprintf('Unexpected token "%s".', $remain)); + } } return $value;