Skip to content

Commit

Permalink
Fix some more escaping for .quote()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Waddell authored and Jacob Waddell committed May 20, 2016
1 parent 70e9eb2 commit ace52f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.quote = function (xs) {
return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"';
}
else {
return String(s).replace(/([\\$`()!#&*|><])/g, '\\$1');
return String(s).replace(/([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '\\$1');
}
}).join(' ');
};
Expand Down
20 changes: 10 additions & 10 deletions test/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ test('quote', function (t) {
quote([ '$', '`', '\'' ]),
'\\$ \\` "\'"'
);
t.equal(quote([]), '');
t.equal(quote(["a\nb"]), "'a\nb'");
t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'");
t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"');
t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\){}\\*\\|][\\!");
t.equal(quote(["a\n#\nb"]), "'a\n#\nb'");
t.equal(quote(['><']), '\\>\\<');
t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false');
t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined');
t.end();
t.equal(quote([]), '');
t.equal(quote(["a\nb"]), "'a\nb'");
t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'");
t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"');
t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\)\\{\\}\\*\\|\\]\\[\\!");
t.equal(quote(["a\n#\nb"]), "'a\n#\nb'");
t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}');
t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false');
t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined');
t.end();
});

test('quote ops', function (t) {
Expand Down

0 comments on commit ace52f4

Please sign in to comment.