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

yamlloader: Properly handle colons in inline dicts #47104

Merged
merged 2 commits into from Apr 18, 2018

Conversation

terminalmage
Copy link
Contributor

@terminalmage terminalmage commented Apr 16, 2018

PyYAML's scanner is not written to handle Python's unicode literal strings, since they are not part of the YAML spec. With all strings loaded in the YAML context now being unicode types, this causes errors when scanning the document to construct the next node. The unicode string literal is misidentified as a plain scalar and any colons within it are interpreted as delimiting a mapping node. Since no whitespace appears after the colon, this causes scanning error.

To fix it, we check for this scanning error and reset the scanner's position and check if the first char is the "u" prefix. If so, and if the following char is a quote, then we attempt to scan for a string literal instead.

Resolves #46929.

PyYAML's scanner is not written to handle Python's unicode literal
strings, since they are not part of the YAML spec. With all strings
loaded in the YAML context now being unicode types, this causes errors
when scanning the document to construct the next node. The unicode
string literal is misidentified as a plain scalar and any colons within
it are interpreted as delimiting a mapping node. Since no whitespace appears
after the colon, this causes scanning error.

To fix it, we check for this scanning error and reset the scanner's
position and check if the first char is the "u" prefix. If so, and if
the following char is a quote, then we attempt to scan for a string
literal instead.
Copy link
Contributor

@rallytime rallytime left a comment

Choose a reason for hiding this comment

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

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants