Skip to content

Commit 5799416

Browse files
author
substack
committed
fix for security issue with windows drive letter regex
1 parent c7de931 commit 5799416

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports.quote = function (xs) {
1010
return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"';
1111
}
1212
else {
13-
return String(s).replace(/([A-z]:)?([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '$1\\$2');
13+
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '$1\\$2');
1414
}
1515
}).join(' ');
1616
};

test/quote.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ test('quote windows paths', { skip: 'breaking change, disabled until 2.x' }, fun
4040

4141
t.end()
4242
})
43+
44+
test("chars for windows paths don't break out", function (t) {
45+
var x = '`:\\a\\b'
46+
t.equal(quote([x]), '\\`\\:\\\\a\\\\b')
47+
t.end()
48+
})

0 commit comments

Comments
 (0)