mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Fix.
This commit is contained in:
parent
596a6da241
commit
c1a589c5b6
7078 changed files with 1882834 additions and 319 deletions
45
node_modules/cross-spawn/lib/util/escape.js
generated
vendored
Normal file
45
node_modules/cross-spawn/lib/util/escape.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
// See http://www.robvanderwoude.com/escapechars.php
|
||||
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
||||
|
||||
function escapeCommand(arg) {
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
function escapeArgument(arg, doubleEscapeMetaChars) {
|
||||
// Convert to string
|
||||
arg = `${arg}`;
|
||||
|
||||
// Algorithm below is based on https://qntm.org/cmd
|
||||
|
||||
// Sequence of backslashes followed by a double quote:
|
||||
// double up all the backslashes and escape the double quote
|
||||
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
||||
|
||||
// Sequence of backslashes followed by the end of the string
|
||||
// (which will become a double quote later):
|
||||
// double up all the backslashes
|
||||
arg = arg.replace(/(\\*)$/, '$1$1');
|
||||
|
||||
// All other backslashes occur literally
|
||||
|
||||
// Quote the whole thing:
|
||||
arg = `"${arg}"`;
|
||||
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
// Double escape meta chars if necessary
|
||||
if (doubleEscapeMetaChars) {
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
module.exports.command = escapeCommand;
|
||||
module.exports.argument = escapeArgument;
|
Loading…
Add table
Add a link
Reference in a new issue