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 String offset cast error in Inline parser #20335

Merged
merged 1 commit into from Nov 2, 2016

Conversation

romainneutron
Copy link
Contributor

Q A
Branch? 3.2/master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT

*/
public function testStringOffsetCastError()
{
Inline::parse('{this, is not, yaml}');
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually this is valid and should be equivalent to { this: ~, is not: ~, yaml: ~ }.

Copy link
Member

Choose a reason for hiding this comment

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

You are right. But this string wasn't even parsed before, was it? But we should nonetheless choose a better failing test case here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly i have no idea if it worked, this part of the code is really hard to understand and i'm certain it leads to unexpected behaviors (by reading it, i think { foo bar } results to { foo: bar }).
I don't think this is the right fix even if it would prevent some unexpected behaviors, this part of the code has to be rewritten to be clearer and more testable.

@GuilhemN
Copy link
Contributor

GuilhemN commented Oct 28, 2016

BTW my PR already fixes that but does a lot of stuff at the same time.

@romainneutron
Copy link
Contributor Author

As we're already in a release candidate status for 3.2, adding new features is not possible. If you have a better fix, just let me know @Ener-Getick . This patch solves an issue in the current version

@GuilhemN
Copy link
Contributor

GuilhemN commented Oct 30, 2016

Then let's wait for 3.3, but i don't think making invalid something that should be valid is a solution.

@nicolas-grekas
Copy link
Member

👍
at least we won't miserably fail with a PHP Warning :)
and throwing a parse error for a syntax not supported by the current parser is fine for now IMHO.

@GuilhemN
Copy link
Contributor

GuilhemN commented Nov 2, 2016

I reviewed your pr again and it looks like indeed that the input you test resulted at least in a warning as @nicolas-grekas said.
So i'm 👍 for this, it can't hurt (it should probably be merged in 2.7).

@nicolas-grekas
Copy link
Member

Checked: this is for master only, 2.7 already fails properly here, the strpos is new to 3.2.

@nicolas-grekas
Copy link
Member

See #20388 on 2.7

@fabpot
Copy link
Member

fabpot commented Nov 2, 2016

Thank you @romainneutron.

@fabpot fabpot merged commit bc095a5 into symfony:master Nov 2, 2016
fabpot added a commit that referenced this pull request Nov 2, 2016
…inneutron)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Yaml] Fix String offset cast error in Inline parser

| Q | A |
| --- | --- |
| Branch? | 3.2/master |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | N/A |
| License | MIT |

Commits
-------

bc095a5 [Yaml] Fix String offset cast error in Inline parser
fabpot added a commit that referenced this pull request Nov 2, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

[Yaml] Clean some messages + add test case

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Related to #20335 on 3.2.

Commits
-------

7520f7b [Yaml] Clean some messages + add test case
@romainneutron romainneutron deleted the fix-yaml-string-offset-cast branch November 8, 2016 13:59
@fabpot fabpot mentioned this pull request Nov 17, 2016
stof added a commit that referenced this pull request Feb 17, 2017
This PR was merged into the 3.2 branch.

Discussion
----------

[Yaml] consistently parse omitted keys as the colon

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Before the changes made in #20335, an empty mapping key was parsed as `:`. This behaviour is not correct according to the spec, but we should keep the parser behaviour consistent to not break backward compatibility (I will deprecate it in a different PR on `master`).

Commits
-------

e2ebecc consistently parse omitted keys as the colon
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