Skip to content

Commit

Permalink
fix for security issue with windows drive letter regex
Browse files Browse the repository at this point in the history
  • Loading branch information
substack committed Oct 21, 2021
1 parent c7de931 commit 5799416
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -10,7 +10,7 @@ exports.quote = function (xs) {
return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"';
}
else {
return String(s).replace(/([A-z]:)?([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '$1\\$2');
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '$1\\$2');
}
}).join(' ');
};
Expand Down
6 changes: 6 additions & 0 deletions test/quote.js
Expand Up @@ -40,3 +40,9 @@ test('quote windows paths', { skip: 'breaking change, disabled until 2.x' }, fun

t.end()
})

test("chars for windows paths don't break out", function (t) {
var x = '`:\\a\\b'
t.equal(quote([x]), '\\`\\:\\\\a\\\\b')
t.end()
})

0 comments on commit 5799416

Please sign in to comment.