mirror of
https://github.com/dorny/paths-filter.git
synced 2025-06-08 00:59:04 +00:00
Simplify shell escaping - escape chars instead of quoting whole string
This commit is contained in:
parent
44ac6d8e25
commit
ada1eee648
3 changed files with 19 additions and 17 deletions
7
dist/index.js
vendored
7
dist/index.js
vendored
|
@ -15222,12 +15222,11 @@ module.exports = require("fs");
|
|||
|
||||
"use strict";
|
||||
|
||||
// Credits to https://github.com/xxorax/node-shell-escape
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Uses easy safe set of characters which can be left unescaped to keep it readable.
|
||||
// Every other character will be backslash-escaped
|
||||
function shellEscape(value) {
|
||||
return `'${value.replace(/'/g, "'\\''")}'`
|
||||
.replace(/^(?:'')+/g, '') // unduplicate single-quote at the beginning
|
||||
.replace(/\\'''/g, "\\'"); // remove non-escaped single-quote if there are enclosed between 2 escaped
|
||||
return value.replace(/([^a-zA-Z0-9,._+:@%/-])/gm, '\\$1');
|
||||
}
|
||||
exports.default = shellEscape;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue