-
-
Notifications
You must be signed in to change notification settings - Fork 797
Closed
Description
As title.
Test Code
const jsYaml = require("js-yaml");
const fs = require("fs");
const yamlStr = jsYaml.dump({ url: "https://github.com/nodeca/js-yaml" });
fs.writeFileSync("foo.yml", yamlStr, { encoding: "utf8" });Expected Result
url: https://github.com/nodeca/js-yamlActual Result
url: 'https://github.com/nodeca/js-yaml'Problem
Line 294 in b6d2609
| plain = plain && isPlainSafe(char); |
Lines 192 to 205 in b6d2609
| function isPlainSafe(c) { | |
| // Uses a subset of nb-char - c-flow-indicator - ":" - "#" | |
| // where nb-char ::= c-printable - b-char - c-byte-order-mark. | |
| return isPrintable(c) && c !== 0xFEFF | |
| // - c-flow-indicator | |
| && c !== CHAR_COMMA | |
| && c !== CHAR_LEFT_SQUARE_BRACKET | |
| && c !== CHAR_RIGHT_SQUARE_BRACKET | |
| && c !== CHAR_LEFT_CURLY_BRACKET | |
| && c !== CHAR_RIGHT_CURLY_BRACKET | |
| // - ":" - "#" | |
| && c !== CHAR_COLON | |
| && c !== CHAR_SHARP; | |
| } |
All of these characters ( except0xFEFF ) are safe inside string. Only colon cannot be followed by space or placed at the end of line.
thetumper and zyberspace
Metadata
Metadata
Assignees
Labels
No labels