Skip to content
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

Add equals sign to list of unsafe values for plain styling #519

Merged
merged 9 commits into from Oct 17, 2019
6 changes: 4 additions & 2 deletions lib/js-yaml/dumper.js
Expand Up @@ -23,6 +23,7 @@ var CHAR_ASTERISK = 0x2A; /* * */
var CHAR_COMMA = 0x2C; /* , */
var CHAR_MINUS = 0x2D; /* - */
var CHAR_COLON = 0x3A; /* : */
var CHAR_EQUALS = 0x3D; /* = */
var CHAR_GREATER_THAN = 0x3E; /* > */
var CHAR_QUESTION = 0x3F; /* ? */
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
Expand Down Expand Up @@ -220,16 +221,17 @@ function isPlainSafeFirst(c) {
&& c !== CHAR_RIGHT_SQUARE_BRACKET
&& c !== CHAR_LEFT_CURLY_BRACKET
&& c !== CHAR_RIGHT_CURLY_BRACKET
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'
&& c !== CHAR_SHARP
&& c !== CHAR_AMPERSAND
&& c !== CHAR_ASTERISK
&& c !== CHAR_EXCLAMATION
&& c !== CHAR_VERTICAL_LINE
&& c !== CHAR_EQUALS
&& c !== CHAR_GREATER_THAN
&& c !== CHAR_SINGLE_QUOTE
// | “"” | “%” | “@” | “`”)
murtazajafferji marked this conversation as resolved.
Show resolved Hide resolved
&& c !== CHAR_DOUBLE_QUOTE
// | “%” | “@” | “`”)
&& c !== CHAR_PERCENT
&& c !== CHAR_COMMERCIAL_AT
&& c !== CHAR_GRAVE_ACCENT;
Expand Down
10 changes: 10 additions & 0 deletions test/issues/0519.js
@@ -0,0 +1,10 @@
'use strict';

var assert = require('assert');
var yaml = require('../../');

test('Loader should not strip quotes for lines containing equals sign', function () {
murtazajafferji marked this conversation as resolved.
Show resolved Hide resolved
var line_with_equals_sign = "'='\n";
var result_of_load_and_dump = yaml.dump(yaml.load(line_with_equals_sign));
assert.strictEqual(line_with_equals_sign, result_of_load_and_dump);
});
murtazajafferji marked this conversation as resolved.
Show resolved Hide resolved