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

Doesn't quote colons #43

Closed
rix0rrr opened this issue Nov 6, 2018 · 3 comments
Closed

Doesn't quote colons #43

rix0rrr opened this issue Nov 6, 2018 · 3 comments
Labels
bug Something isn't working

Comments

@rix0rrr
Copy link

rix0rrr commented Nov 6, 2018

Not sure about the exact spec (if more special characters need to be quoted and maybe in other combinations), but at least this library doesn't quote single colons, which leads it to generate invalid YAML:

$ npm init
...
$ npm install yaml
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN pkg@1.0.0 No description
npm WARN pkg@1.0.0 No repository field.

+ yaml@1.0.0
added 1 package in 0.825s

$ node -p "require('yaml').stringify({ key: ':' })"
key: :

# PyYaml doesn't like it:

$ python3 -c 'import yaml; from io import StringIO; print(yaml.load(StringIO("key: :")))'
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<file>", line 1, column 6
@eemeli eemeli added the bug Something isn't working label Nov 7, 2018
@eemeli
Copy link
Owner

eemeli commented Nov 7, 2018

That is indeed a bug. To verify, even we complain about it:

YAML.parse(YAML.stringify({ key: ':' }))
// YAMLSemanticError: Nested Mappings are not allowed in compact mappings

@eemeli eemeli closed this as completed in b99ff5e Nov 7, 2018
@rix0rrr
Copy link
Author

rix0rrr commented Nov 7, 2018

Thanks for the speedy fix!

@eemeli
Copy link
Owner

eemeli commented Nov 7, 2018

Fix released in version 1.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants