-
-
Notifications
You must be signed in to change notification settings - Fork 788
Open
Description
In YAML 1.1, numeric scalars with leading zeros that include characters 8 or 9 do not need to be quoted. For example, the scalar 083 must be a string as it can't be a valid octal value. In YAML 1.2, 083 is interpreted as a number.
My understanding is that a YAML directive in a YAML document should allow a YAML processor to distinguish between these specifications. For example, given the following document:
%YAML 1.1
--- 083The yaml processor should know to interpret the scalar 083 as the string "083" instead of as the number 83. js-yaml interprets the value as the number 83. Here's an example package.json and index.js
{
"dependencies": {
"js-yaml": "^4.1.0"
}
}const yaml = require('js-yaml');
const unquoted = "%YAML 1.1\n--- 083\n";
const quoted = "%YAML 1.1\n--- '083'\n";
const vals = [unquoted, quoted];
for (const val of vals) {
console.log(">>>START<<<");
console.log(val);
console.log(">>>END<<<");
console.log(yaml.load(val));
}% node index.js
>>>START<<<
%YAML 1.1
--- 083
>>>END<<<
83
>>>START<<<
%YAML 1.1
--- '083'
>>>END<<<
083
I'd expect both of these to parse as the string "083" given the %YAML 1.1 directive.
wemod123 and agilgur5
Metadata
Metadata
Assignees
Labels
No labels