Detailansicht verbessert
This commit is contained in:
30
express-server/node_modules/cross-spawn/lib/util/escapeArgument.js
generated
vendored
Normal file
30
express-server/node_modules/cross-spawn/lib/util/escapeArgument.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
function escapeArgument(arg, quote) {
|
||||
// Convert to string
|
||||
arg = '' + arg;
|
||||
|
||||
// If we are not going to quote the argument,
|
||||
// escape shell metacharacters, including double and single quotes:
|
||||
if (!quote) {
|
||||
arg = arg.replace(/([()%!^<>&|;,"'\s])/g, '^$1');
|
||||
} else {
|
||||
// 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 + '"';
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
module.exports = escapeArgument;
|
12
express-server/node_modules/cross-spawn/lib/util/escapeCommand.js
generated
vendored
Normal file
12
express-server/node_modules/cross-spawn/lib/util/escapeCommand.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var escapeArgument = require('./escapeArgument');
|
||||
|
||||
function escapeCommand(command) {
|
||||
// Do not escape if this command is not dangerous..
|
||||
// We do this so that commands like "echo" or "ifconfig" work
|
||||
// Quoting them, will make them unaccessible
|
||||
return /^[a-z0-9_-]+$/i.test(command) ? command : escapeArgument(command, true);
|
||||
}
|
||||
|
||||
module.exports = escapeCommand;
|
18
express-server/node_modules/cross-spawn/lib/util/hasEmptyArgumentBug.js
generated
vendored
Normal file
18
express-server/node_modules/cross-spawn/lib/util/hasEmptyArgumentBug.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
// See: https://github.com/IndigoUnited/node-cross-spawn/pull/34#issuecomment-221623455
|
||||
function hasEmptyArgumentBug() {
|
||||
var nodeVer;
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
return false;
|
||||
}
|
||||
|
||||
nodeVer = process.version.substr(1).split('.').map(function (num) {
|
||||
return parseInt(num, 10);
|
||||
});
|
||||
|
||||
return (nodeVer[0] === 0 && nodeVer[1] < 12);
|
||||
}
|
||||
|
||||
module.exports = hasEmptyArgumentBug();
|
37
express-server/node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
37
express-server/node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var LRU = require('lru-cache');
|
||||
var shebangCommand = require('shebang-command');
|
||||
|
||||
var shebangCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
|
||||
|
||||
function readShebang(command) {
|
||||
var buffer;
|
||||
var fd;
|
||||
var shebang;
|
||||
|
||||
// Check if it is in the cache first
|
||||
if (shebangCache.has(command)) {
|
||||
return shebangCache.get(command);
|
||||
}
|
||||
|
||||
// Read the first 150 bytes from the file
|
||||
buffer = new Buffer(150);
|
||||
|
||||
try {
|
||||
fd = fs.openSync(command, 'r');
|
||||
fs.readSync(fd, buffer, 0, 150, 0);
|
||||
fs.closeSync(fd);
|
||||
} catch (e) { /* empty */ }
|
||||
|
||||
// Attempt to extract shebang (null is returned if not a shebang)
|
||||
shebang = shebangCommand(buffer.toString());
|
||||
|
||||
// Store the shebang in the cache
|
||||
shebangCache.set(command, shebang);
|
||||
|
||||
return shebang;
|
||||
}
|
||||
|
||||
module.exports = readShebang;
|
31
express-server/node_modules/cross-spawn/lib/util/resolveCommand.js
generated
vendored
Normal file
31
express-server/node_modules/cross-spawn/lib/util/resolveCommand.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var which = require('which');
|
||||
var LRU = require('lru-cache');
|
||||
|
||||
var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
|
||||
|
||||
function resolveCommand(command, noExtension) {
|
||||
var resolved;
|
||||
|
||||
noExtension = !!noExtension;
|
||||
resolved = commandCache.get(command + '!' + noExtension);
|
||||
|
||||
// Check if its resolved in the cache
|
||||
if (commandCache.has(command)) {
|
||||
return commandCache.get(command);
|
||||
}
|
||||
|
||||
try {
|
||||
resolved = !noExtension ?
|
||||
which.sync(command) :
|
||||
which.sync(command, { pathExt: path.delimiter + (process.env.PATHEXT || '') });
|
||||
} catch (e) { /* empty */ }
|
||||
|
||||
commandCache.set(command + '!' + noExtension, resolved);
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
module.exports = resolveCommand;
|
Reference in New Issue
Block a user