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-yaml
Actual Result
url: 'https://github.com/nodeca/js-yaml'
Problem
|
plain = plain && isPlainSafe(char); |
|
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.
As title.
Test Code
Expected Result
Actual Result
Problem
js-yaml/lib/js-yaml/dumper.js
Line 294 in b6d2609
js-yaml/lib/js-yaml/dumper.js
Lines 192 to 205 in b6d2609
All of these characters ( except
0xFEFF) are safe inside string. Only colon cannot be followed by space or placed at the end of line.