Skip to content

Commit

Permalink
check if there is a forbidden character in commandName
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel59 committed Oct 12, 2018
1 parent db45a2f commit 4af96dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/command-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ var commandExistsUnix = function(commandName, cleanedCommandName, callback) {
}

var commandExistsWindows = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
callback(null, false);
return;
}
var child = exec('where ' + cleanedCommandName,
function (error) {
if (error !== null){
Expand Down Expand Up @@ -89,6 +93,9 @@ var commandExistsUnixSync = function(commandName, cleanedCommandName) {
}

var commandExistsWindowsSync = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
return false;
}
try {
var stdout = execSync('where ' + cleanedCommandName, {stdio: []});
return !!stdout;
Expand Down

0 comments on commit 4af96dc

Please sign in to comment.