dump fails to quote strings with leading zeros if any chars are non-octal
See original GitHub issuejsyaml = require('js-yaml');
console.log(jsyaml.dump("007"));
console.log(jsyaml.dump("008"));
Should output
'007'
'008'
but it outputs
'007'
008
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 to chooseScalarStyle
in dumper.js
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How to dump a digit string with leading zeros, as a valid yaml ...
Creating a yaml string with leading zeros is not escaped with quotes in yaml-cpp. So writing the string to a texfile is not...
Read more >perldiag - ActivePerl 5.26 Documentation
(P) An error peculiar to VMS. Perl thought stdin was a pipe, and tried to reopen it to accept binary data. Alas, it...
Read more >HON EYVVE LL . - Bitsavers.org
If no match strings are supplied, no string matching is ... dumped to see the events leading up to a particular error condition,...
Read more >Проект OpenNet: MAN zshbuiltins (1) Команды и прикладные ...
If no command is specified, print the binding of in-string if it is bound, ... the zero; a non-octal digit ter- minates the...
Read more >RfD: Escaped Strings - Google Groups
corresponds to the current ANS definition of a character. ... \q double-quote (ASCII 34) ... \[0-7]+ Octal numerical character value, finishes at the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
If you need quick and dirty workaround - use JSON.stringify(), it’s compatible with yaml.