symfony: Regression in Symfony Yaml Parser
| Q | A |
|---|---|
| Bug report? | yes |
| Feature request? | no |
| BC Break report? | no |
| RFC? | no |
| Symfony version | 3.3.14, 3.4.1 and 4.0.1 |
Hi,
Since the latest 3.3, I experiment a regression in Symfony Yaml, here’s a reproducer:
<?php
require __DIR__.'/vendor/autoload.php';
$yaml = <<<EOYAML
root:
- key1: "bim"
# A comment
key2: "boum"
EOYAML;
$parser = new Symfony\Component\Yaml\Parser();
dump($parser->parse($yaml));
expected outpout:
array:1 [
"root" => array:1 [
0 => array:2 [
"key1" => "bim"
"key2" => "boum"
]
]
]
actual output:
PHP Fatal error: Uncaught Symfony\Component\Yaml\Exception\ParseException: Unable to parse at line 4 (near " key2: "boum""). in /Users/neutron/Documents/workspace/symfony/src/Symfony/Component/Yaml/Parser.php:426
Stack trace:
#0 /Users/neutron/Documents/workspace/symfony/src/Symfony/Component/Yaml/Parser.php(465): Symfony\Component\Yaml\Parser->doParse('- key1: "bim"\n ...', 0)
#1 /Users/neutron/Documents/workspace/symfony/src/Symfony/Component/Yaml/Parser.php(315): Symfony\Component\Yaml\Parser->parseBlock(1, '- key1: "bim"\n ...', 0)
#2 /Users/neutron/Documents/workspace/symfony/src/Symfony/Component/Yaml/Parser.php(95): Symfony\Component\Yaml\Parser->doParse('root:\n - key1:...', 0)
#3 /Users/neutron/Documents/workspace/symfony/test.php(15): Symfony\Component\Yaml\Parser->parse('root:\n - key1:...')
#4 {main}
thrown in /Users/neutron/Documents/workspace/symfony/src/Symfony/Component/Yaml/Parser.php on line 426
I’ve tested against all latest versions, only version 3.3.14, 3.4.1 and 4.0.1 are affected
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 21 (18 by maintainers)
Commits related to this issue
- Force Symfony 3.4.0 because of regression in 3.4.1 Issue: https://github.com/symfony/symfony/issues/25329 — committed to ezsystems/ezplatform by Nattfarinn 7 years ago
- Force Symfony 3.4.0 because of regression in 3.4.1 Issue: https://github.com/symfony/symfony/issues/25329 — committed to ezsystems/ezplatform-ee by Nattfarinn 7 years ago
- bug #25389 [Yaml] fix some edge cases with indented blocks (xabbuh) This PR was merged into the 3.3 branch. Discussion ---------- [Yaml] fix some edge cases with indented blocks | Q | ... — committed to symfony/symfony by nicolas-grekas 7 years ago
Thanks for the examples. I am currently working on a fix. Sorry for the inconvenience.
@xabbuh Yes, with the changes it works for me. Thanks!
Can everyone affected by the described issue confirm that #25389 fixes it?