Skip to content

[Yaml] Deal with lines containing whitespace ONLY in multiline parser. #31369

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

Closed
wants to merge 1 commit into from
Closed

[Yaml] Deal with lines containing whitespace ONLY in multiline parser. #31369

wants to merge 1 commit into from

Conversation

crayner
Copy link

@crayner crayner commented May 3, 2019

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #31333
License MIT
Doc PR n/a

This PR ignores lines in a YAML file that contain whitespace ONLY, effectively an empty line as far as the parser is concerned.

Speed:
Over 100 iterations compared to libYaml in PHP 7.3.4 on WAMP64 installation the average speed ratio is approx. 3.5:1 (SymfonyParser:libYaml) for data = "{\n \n}"

@crayner
Copy link
Author

crayner commented May 3, 2019

One test added. and compared against libYAML operation. Sorry about the mess in commits.

@stof
Copy link
Member

stof commented May 3, 2019

The list of commits in your branch seems to be a mess.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone May 5, 2019
@nicolas-grekas
Copy link
Member

@crayner can you please rebase+squash on branch 3.4? That should clean the git history.

@crayner
Copy link
Author

crayner commented May 5, 2019

HI @nicolas-grekas , I tried to do the rebase-squash as suggested. Result may now be worse. Let me know. Happy to close request and rebuild form scratch given < 10 lines of code.

@fabpot
Copy link
Member

fabpot commented May 6, 2019

@crayner It looks like you merged instead of rebasing (one great thing about rebasing is that it removes the merge commits, which prevent us from merging a pull request). You can find more information here: https://symfony.com/doc/current/contributing/code/pull_requests.html#rebase-your-pull-request

If you want to, I will happily do it for you.

@crayner
Copy link
Author

crayner commented May 6, 2019

Thanks @fabpot , I will have another go, as that is how one learns.

@crayner
Copy link
Author

crayner commented May 7, 2019

Tried again, with a lot of errors at the git rebase --continue as there were NO changes. Do not know what I was doing wrong.

but: tried PHPStorm script and it seemed to work? If it has not work as expected, please go ahead and rebase squash.

@stof
Copy link
Member

stof commented May 7, 2019

what if this kind of structure does not appear as top-level ?

@crayner
Copy link
Author

crayner commented May 7, 2019

Thanks @xabbuh

@crayner
Copy link
Author

crayner commented May 8, 2019

@stof This will still fail in the existing parser code. A different fix?

what if this kind of structure does not appear as top-level ?

…denormalizer of DateTimeNormalizer

Code Style variations

Deal with lines containing whitespace ONLY in multiline parser.

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Restore normal string operation of multiline when NOT embedded in {} or []

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Remove empty

Coding Standard

Deal with lines containing whitespace ONLY in multiline parser.

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Restore normal string operation of multiline when NOT embedded in {} or []

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Deal with leak of Normaliser Work

Remove empty

Coding Standard
@xabbuh
Copy link
Member

xabbuh commented Jun 8, 2019

In the past we decided not to support the JSON syntax in the YAML parser (see for example #18968). I would agree on a PR throwing a (more) meaningful exception when we detect such structures, but I am against supporting it only partially.

@Simperfit
Copy link
Contributor

@crayner can you do the PR ?

@crayner
Copy link
Author

crayner commented Jun 15, 2019

Not sure I agree, therefore would like to see other opinions! What do you think @ylixir. This is not really a JSON fix, but a whitespace issue, IMHO.

@ylixir
Copy link

ylixir commented Jun 15, 2019

I think four things:

  1. yes, it is clearly a whitespace issue
  2. This is a very basic example, not some weird edge case. Standards matter. If we aren't making a yaml parser maybe don't call it a yaml parser.
  3. The fact that this continues to come up in multiple issues means it's a real problem. In my case it's machine generated yaml, so it's not like i can just tweak the syntax
  4. If this thing isn't a yaml parser, then whatever this thing can and can't parse should be documented. If this bug isn't going to be fixed, then the pr should be a documentation update instead of a bug fix.

@xabbuh
Copy link
Member

xabbuh commented Sep 21, 2019

I have spent some time on parsing the inline notation when it spans mutliple lines (see #33658). That PR would land as a new feature in Symfony 4.4. I suggest to close here in favour of the new PR.

@nicolas-grekas
Copy link
Member

Closing in favor of #33658 as suggested by @xabbuh

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.

8 participants