-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
6.1.0
Description
The parser fails to parse multi-line literal syntax in combination with tags.
See the example below.
It should be allowed. E.g. on you find this:
Example 2.23 Various Explicit Tags
--- not-date: !!str 2002-04-28 picture: !!binary | R0lGODlhDAAMAIQAAP//9/X 17unp5WZmZgAAAOfn515eXv Pz7Y6OjuDg4J+fn5OTk6enp 56enmleECcgggoBADs= application specific tag: !something | The semantics of the tag above may be different for different documents.
How to reproduce
The following can be added to ParserTest.
The test will pass, which means the parser does not work correctly.
public function testTaggedTextAsListItem() {
$yml = <<<'YAML'
- !text |
first line
YAML;
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Unable to parse at line 3 (near "!text |").');
$this->parser->parse($yml, Yaml::PARSE_CUSTOM_TAGS);
}
Without the ->expectException
I get this:
1) Symfony\Component\Yaml\Tests\ParserTest::testTaggedValuesAsListItems
Symfony\Component\Yaml\Exception\ParseException: Unable to parse at line 14 (near "!text |-").
[..]/Parser.php:483
[..]/Parser.php:523
[..]/Parser.php:194
[..]/Parser.php:86
[..]/Tests/ParserTest.php:115
Possible Solution
Fix somewhere in Parser.
I have not studied this class enough yet to propose anything better.
Additional Context
No response