Thanks to visit codestin.com
Credit goes to github.com

Skip to content

symfony/yaml does not parse tabs after colon #40507

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
bertramakers opened this issue Mar 18, 2021 · 0 comments
Closed

symfony/yaml does not parse tabs after colon #40507

bertramakers opened this issue Mar 18, 2021 · 0 comments

Comments

@bertramakers
Copy link
Contributor

bertramakers commented Mar 18, 2021

Symfony version(s) affected: 4.4.19

Description
symfony/yaml throws a Symfony\Component\Yaml\Exception\ParseException if it encounters a tab instead of space(s) after a colon, while tabs are valid as separation between tokens within a line according to the yaml spec: https://yaml.org/spec/1.2/spec.html#id2778241

Outside indentation and scalar content, YAML uses white space characters for separation between tokens within a line. Note that such white space may safely include tab characters.

(Emphasis mine)

How to reproduce
Use symfony/yaml to parse a yaml file with a tab after the colon of a key/value pair on a line.

For example:

'00D24000000JRFx:0012400000R6XYH':	95290dcc-8d1d-4b9f-952e-496562f53e35

Possible Solution
Allow tabs for separation between tokens within a line, as described in the yaml spec.
If I find some time I might look into a possible fix and make a PR myself unless someone else beats me to it.

Additional context
It has been mentioned in other issues like #15674 that tabs are not allowed in yaml files. But this is only the case for indentation.

While I'm not a huge fan of it personally, it's an issue when a different linter tells us that a given YAML file with content that we have little control over has valid syntax in an unrelated check, and then our app crashes because it cannot be parsed after all.

@derrabus derrabus added the Yaml label Mar 18, 2021
xabbuh added a commit that referenced this issue Apr 23, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

[Yaml] Allow tabs as separators between tokens

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #40507
| License       | MIT
| Doc PR        | None

As described in #40507, the Yaml spec allows tabs as whitespace characters between tokens. However, the Yaml parser crashes on this as it only expects spaces after the colon. https://yaml.org/spec/1.2/spec.html#id2778241

While I'm not a huge fan of it personally, it's an issue when a different linter tells us that a given YAML file with content that we have little control over has valid syntax in an unrelated check, and then our app crashes because it cannot be parsed after all.

Commits
-------

9a130ae Fix issue 40507: Tabs as separators between tokens
@xabbuh xabbuh closed this as completed Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants