Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments confuse the YAML parser #32952

Closed
tamasd opened this issue Aug 5, 2019 · 6 comments
Closed

Comments confuse the YAML parser #32952

tamasd opened this issue Aug 5, 2019 · 6 comments

Comments

@tamasd
Copy link

tamasd commented Aug 5, 2019

Symfony version(s) affected: 3.x, 4.x

Description
The Symfony YAML parser component fails to parse a valid YAML file, that can be parsed by other parsers (e.g. spyc).

How to reproduce
This example file is the simplified version (smallest one that can reproduce this issue) of the file I am trying to parse.

foo:
  bar:
    baz:
      {
      }

  # asdf

  ### qwer

The result is:

Unable to parse at line 4 (near "{").
#0 /app/vendor/symfony/yaml/Parser.php(520): Symfony\Component\Yaml\Parser->doParse(' { }\n# asdf\n###...', 0)
#1 /app/vendor/symfony/yaml/Parser.php(373): Symfony\Component\Yaml\Parser->parseBlock(3, '{\n}\n\n# asdf\n\n##...', 0)
#2 /app/vendor/symfony/yaml/Parser.php(520): Symfony\Component\Yaml\Parser->doParse('baz:\n  {\n  }\n\n#...', 0)
#3 /app/vendor/symfony/yaml/Parser.php(373): Symfony\Component\Yaml\Parser->parseBlock(2, 'baz:\n  {\n  }\n\n#...', 0)
#4 /app/vendor/symfony/yaml/Parser.php(520): Symfony\Component\Yaml\Parser->doParse('bar:\n  baz:\n   ...', 0)
#5 /app/vendor/symfony/yaml/Parser.php(373): Symfony\Component\Yaml\Parser->parseBlock(1, 'bar:\n  baz:\n   ...', 0)
#6 /app/vendor/symfony/yaml/Parser.php(142): Symfony\Component\Yaml\Parser->doParse('foo:\n  bar:\n   ...', 0)
#7 /app/vendor/symfony/yaml/Yaml.php(110): Symfony\Component\Yaml\Parser->parse('foo:\n  bar:\n   ...', 0)
#8 /app/src/Test.php(9): Symfony\Component\Yaml\Yaml::parse('foo:\n  bar:\n   ...')
#9 /app/src/Test.php(25): {closure}('foo:\n  bar:\n   ...')
@xabbuh
Copy link
Member

xabbuh commented Aug 5, 2019

Does this not happen if your YAML looks like this?

foo:
  bar:
    baz:
      {
      }

@pierredup
Copy link
Contributor

pierredup commented Aug 5, 2019

#32767 fixes this issue (I tested with multiple scenarios, and applying the patch from #32767 fixes all the cases)

@tamasd
Copy link
Author

tamasd commented Aug 6, 2019

No, it does not. The two comment blocks need to be there.

@xabbuh
Copy link
Member

xabbuh commented Aug 6, 2019

Then I am pretty sure that this behaviour is related to the fact that the component doesn't parse the inline notation when it spans multiple lines (see also #25239). So let's close here as a duplicate of the mentioned issue.

@xabbuh xabbuh closed this as completed Aug 6, 2019
@pierredup
Copy link
Contributor

@tamasd Please try the fix in #32767, that definitely fixes the issue here

@tamasd
Copy link
Author

tamasd commented Aug 6, 2019

@pierredup applying the patch from that pull request on top of 3.4.30 fixed the issue. Thanks for the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants