Skip to content

[Yaml Parser] fixed Parser to skip comments when inlining sequences #38040

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

Merged
merged 1 commit into from
Sep 6, 2020
Merged

[Yaml Parser] fixed Parser to skip comments when inlining sequences #38040

merged 1 commit into from
Sep 6, 2020

Conversation

korve
Copy link
Contributor

@korve korve commented Sep 2, 2020

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #37972
License MIT

The parser didn't skip comments when parsing values in a sequence. This resulted in the YamlFileLoader trying to
parse a comment as a IteratorArgument which resulted in a InvalidArgumentException.

Consider the following valid yaml:

- !foo [
    bar,
    #baz
  ]

The parser would generate the following array:

['bar', '#baz']

After this fix the parser will generate the following array:

['bar']

This bug only appeared for me in 4.4

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having a look and submitting.

]]
YAML
],
'with-comments-trailing-comma' => [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see how this test case differs from the previous one.

Copy link
Contributor Author

@korve korve Sep 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops you're right. The 'with-comments' was meant to be without a comma after the 2nd array element. I've fixed it.

@fabpot fabpot added the Yaml label Sep 6, 2020
@fabpot
Copy link
Member

fabpot commented Sep 6, 2020

Thank you @korve.

@fabpot fabpot merged commit f0bf853 into symfony:4.4 Sep 6, 2020
This was referenced Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants