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

Plain scalars with colons inside flow mappings & sequences are valid YAML #295

Closed
jstoiko opened this issue Dec 23, 2017 · 2 comments
Closed

Comments

@jstoiko
Copy link

jstoiko commented Dec 23, 2017

Scalars with colons, such as URLs, when they are inside flow mappings, e.g.

a: {b: https://github.com/go-yaml/yaml}

and sequences, e.g.

a: [https://github.com/go-yaml/yaml]

make go-yaml choke with found unexpected ':'.

The specs however explicitly allow it:

Normally, YAML insists the “:” mapping value indicator be separated from the value by white space. A benefit of this restriction is that the “:” character can be used inside plain scalars, as long as it is not followed by white space. This allows for unquoted URLs and timestamps.

On a related note, libyaml (the reference parser for YAML in C) had a similar issue but it seems to have been addressed and about to be released.

rogpeppe added a commit to rogpeppe-contrib/yaml that referenced this issue Jan 5, 2018
We copy the same fix from the original libyaml code.

Fixes issue go-yaml#295.
rogpeppe added a commit to rogpeppe-contrib/yaml that referenced this issue Jan 5, 2018
We copy the same fix from the original libyaml code.

Fixes issue go-yaml#295.
@rogpeppe
Copy link
Contributor

rogpeppe commented Jan 6, 2018

Fixed in devel branch by PR #305

@asomov
Copy link

asomov commented Feb 3, 2018

I see no tests added for the failing corner cases:

{a: 1}
{a:1}
{a:}

djgilcrease pushed a commit to djgilcrease/yaml that referenced this issue Mar 14, 2018
We copy the same fix from the original libyaml code.

Fixes issue go-yaml#295.
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

No branches or pull requests

3 participants