diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 2a15bcae3d157..6d7064e07abb8 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1158,7 +1158,7 @@ private function lexInlineQuotedString(int &$cursor = 0): string private function lexUnquotedString(int &$cursor): string { $offset = $cursor; - $cursor += strcspn($this->currentLine, '[]{},: ', $cursor); + $cursor += strcspn($this->currentLine, '[]{},:', $cursor); if ($cursor === $offset) { throw new ParseException('Malformed unquoted YAML string.'); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 3c4c071135855..23119f92176b8 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1710,6 +1710,33 @@ public function testBackslashInQuotedMultiLineString() $this->assertSame($expected, $this->parser->parse($yaml)); } + /** + * @dataProvider wrappedUnquotedStringsProvider + */ + public function testWrappedUnquotedStringWithMultipleSpacesInValue(string $yaml, array $expected) + { + $this->assertSame($expected, $this->parser->parse($yaml)); + } + + public static function wrappedUnquotedStringsProvider() { + return [ + 'mapping' => [ + '{ foo: bar bar, fiz: cat cat }', + [ + 'foo' => 'bar bar', + 'fiz' => 'cat cat', + ] + ], + 'sequence' => [ + '[ bar bar, cat cat ]', + [ + 'bar bar', + 'cat cat', + ] + ], + ]; + } + public function testParseMultiLineUnquotedString() { $yaml = <<