Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Yaml] Allow parsing of unindented closing quotation mark#33119

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
johnillo wants to merge2 commits intosymfony:4.3fromjohnillo:fix/yaml-unindented-close-quote
Closed

[Yaml] Allow parsing of unindented closing quotation mark#33119

johnillo wants to merge2 commits intosymfony:4.3fromjohnillo:fix/yaml-unindented-close-quote

Conversation

@johnillo
Copy link
Contributor

@johnillojohnillo commentedAug 12, 2019
edited by javiereguiluz
Loading

QA
Branch?4.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#33082
LicenseMIT
Doc PRsymfony/symfony-docs#...

Unindented quotation marks are not parsed correctly by the parser. Online parsers accepts values/strings with unindented quotation marks as valid yaml.

$yaml =<<<YAML---foo:  bar: 'baz'YAML;dump($this->parser->parse($yaml));

Before fix

Symfony\Component\Yaml\Exception\ParseException: Malformed inline YAML string: 'baz at line 4.

After fix

array:1 [  "foo" => array:1 [    "bar" => "baz\n"  ]]

@johnillojohnillo changed the titlefix(yml): allow parsing of unindented closing quotation mark.[Yaml] Allow parsing of unindented closing quotation markAug 12, 2019
@xabbuhxabbuh added the Yaml labelAug 12, 2019
@nicolas-grekasnicolas-grekas added this to the4.3 milestoneAug 12, 2019
@javiereguiluz
Copy link
Member

@johnillo thanks for contributing this fix!

I have a question about the number of\n in the parsed result. Shouldn't we get two\n instead of one?

image

johnillo reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

@javiereguiluz:

image

@xabbuh
Copy link
Member

If I do not miss anything, the following YAML string would still not be parsed:

foo:bar:'bazfoobar'

This is due to the fact that the parser does not properly handle the inline notation when split across multiple lines.

From my point of view I would rather invest some time to try to add support for the multi-line notation spanning multiple lines entirely instead of solving it only partially.

derrabus, johnillo, and DavidBadura reacted with thumbs up emoji

@javiereguiluz
Copy link
Member

About the missing\n, I guess it's related to the "line folding" feature of the YAML spec:"When encountering a sequence of (possibly indented) line breaks without any additional intermediate characters, the parser ignores the first one and preserves the rest."

@GuilhemN
Copy link
Contributor

I don't think this is valid Yaml, the spec explicitly refers to the indentation of each line when defining quoted scalars (https://yaml.org/spec/1.1/current.html#l-single-inner(n) ):

s-ignored-prefix(n,single)
( ns-single-char nb-single-char* )?

Ands-ignored-prefix imposes parsing n white spaces before any content.

@fabpot
Copy link
Member

For the record, we don't thrive to support all the YAML spec. And I agree with@xabbuh that if we were going to add support for this new feature, it should be complete. I don't think this is worth it.@johnillo Do you want to give it a try?

@johnillo
Copy link
ContributorAuthor

@fabpot I think I have to agree with you that it's not worth it. I've tried different parsers online and they behave differently on this kind of input.

I'll close this PR. Thanks everyone.

fabpot added a commit that referenced this pull requestFeb 3, 2024
…axbeckers)This PR was submitted for the 5.4 branch but it was merged into the 7.1 branch instead.Discussion----------[Yaml] Fix Yaml Parser with quote end in a new line| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#33082| License       | MIT| Doc PR        | N/AThis 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.Commits-------21cec3f [Yaml] Fix Yaml Parser with quote end in a new line
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

7 participants

@johnillo@javiereguiluz@nicolas-grekas@xabbuh@GuilhemN@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp