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
[Yaml] Fix Yaml Parser with quote end in a new line #48022
base: 5.4
Are you sure you want to change the base?
Conversation
Hey! I think @mamazu has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
67e40af
to
b3cc966
Compare
b3cc966
to
50250dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I'd like to ping @xabbuh also :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried many online parser, written in different languages, which all behave differently.
I would not change the current behavior if the spec is unclear on this, as this would be a BC break.
So, that's a
foo: | ||
bar: 'baz | ||
|
||
' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid YAML AFAIU. The quote must be indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should close this PR and the issue with "Won't fix", because this is exactly the case, what is requested to be fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, this is indeed valid YAML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken some time to read up on this YAML topic. In the internet are two kinds of YAML parser for this topic. Either the content must be indented even if it is in quotes or everything in quotes can be indented free, because the part in quotes is simply considered as a text block.
What I want to say is that the PR should not be merged as it is and we should decide here how to proceed.
Solution A: everything should be how it is and we only support indented quotes, seems to be how it's described in the spec https://yaml.org/spec/1.2.2/#8111-block-indentation-indicator.
foo:
bar: 'baz
'
Solution B: be a bit more generous and allow what requested in the issue and how a lot of online parsers/validators see the quoted part as a string and allow stuff like that:
foo:
bar: 'baz1
baz2
baz3
'
Based on that I'd prefer solution A and keep it how it is as @fabpot mentioned. What do you think?
This is a fix for issue #33082.
The bug described in the ticket breaks on a ending quote in a new line:
Before the fix:
Symfony\Component\Yaml\Exception\ParseException: Malformed inline YAML string: 'baz at line 4.
There was already a PR #33119, which was closed because of problems.