-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebc2539
commit c6da331
Showing
2 changed files
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export const escapeArguments = (args: string[]) => { | ||
return args.map(arg => (arg.includes(' ') ? `"${arg}"` : arg)); | ||
return args.map(arg => { | ||
const escapedArg = arg.replace(/(")/g, '\\$1'); | ||
Check failure Code scanning / CodeQL Incomplete string escaping or encoding High
This does not escape backslash characters in the input.
|
||
|
||
return /\s/.test(escapedArg) ? `"${escapedArg}"` : escapedArg; | ||
}); | ||
}; |