-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
dump fails to quote strings with leading zeros if any chars are non-octal #394
Comments
It looks like the fix needs to go here https://github.com/nodeca/js-yaml/blob/master/lib/js-yaml/dumper.js#L343 |
Everything works as expected. Quotes are not used when not needed. |
They are needed in this case. If the number isn't quoted downstream tooling fails as it is ambigous. I'm going to need to hack around this and am happy to provide a PR. |
Could you provide a proof with refer to spec or well known parser implementations? 008 is NOT a valid octal number. |
You're missing the point, I'm not suggesting 008 is a valid octal number. Rather, CloudFormation and probably other tools are parsing it as number when not quoted. If js-yaml were to quote such strings, this bad interaction could be avoided. |
IMHO it's much better idea to report broken yaml parser in CloudFormation tool, instead of suggest adding kludge to working and correct implementation. |
I'll be reporting it to CloudFormation as well. However, I'd still consider it a valid enhancement to your library. Which strings to consider ambiguous and need quoting, what flow style to use, when to line wrap, etc. are stylistic choices js-yaml is making rather than strict adherence to the YAML spec. |
I respect your opinion, but that's subjective and not enough for changes. |
If you need quick and dirty workaround - use JSON.stringify(), it's compatible with yaml. |
Would you be open to a dump option to always force quoting of single line strings? That feels in line with the types of control the existing options provide and isn't a single-case kludge. |
I'm ok about any option if there are strong arguments why this option is nice & useful for all. But options "just for fun" are rejected to keep api simple. |
Should output
but it outputs
I'm running into this with AWS account ids that start with two leading 0s and this is causing issues with CloudFormation templates as CloudFormation then mangles the numbers further.
This case should be handled in the
testAmbiguousType
function passed tochooseScalarStyle
indumper.js
.The text was updated successfully, but these errors were encountered: