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

[Yaml] Fix Yaml Parser with quote end in a new line #48022

Open
wants to merge 1 commit into
base: 5.4
Choose a base branch
from

Conversation

maxbeckers
Copy link
Contributor

@maxbeckers maxbeckers commented Oct 28, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #33082
License MIT
Doc PR N/A

This is a fix for issue #33082.

The bug described in the ticket breaks on a ending quote in a new line:

foo:
  bar: 'baz

'
  baz: 'Lorem'

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.

@carsonbot
Copy link

Hey!

I think @mamazu has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@maxbeckers maxbeckers force-pushed the patch-33082 branch 2 times, most recently from 67e40af to b3cc966 Compare November 1, 2022 06:22
@fabpot fabpot modified the milestones: 4.4, 5.4 Nov 23, 2022
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.

LGTM but I'd like to ping @xabbuh also :)

Copy link
Member

@fabpot fabpot left a 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 👎 from me for this change.

foo:
bar: 'baz

'
Copy link
Member

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.

Copy link
Contributor Author

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!

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @xabbuh and @fabpot,

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?

xabbuh
xabbuh approved these changes Dec 17, 2022
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.

None yet

6 participants