@e-mc/module 0.6.14 → 0.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -24
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -117,6 +117,8 @@ const VALUES = {
|
|
|
117
117
|
["logger.level"]: -1
|
|
118
118
|
};
|
|
119
119
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
120
|
+
const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
|
|
121
|
+
const REGEXP_CLIOPTION = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/s;
|
|
120
122
|
const RESERVED_SHELL = [
|
|
121
123
|
'if',
|
|
122
124
|
'then',
|
|
@@ -586,7 +588,7 @@ class Module extends EventEmitter {
|
|
|
586
588
|
this[_f] = new AbortController();
|
|
587
589
|
this[_g] = null;
|
|
588
590
|
}
|
|
589
|
-
static get VERSION() { return "0.6.
|
|
591
|
+
static get VERSION() { return "0.6.15"; }
|
|
590
592
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
591
593
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
592
594
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1869,12 +1871,10 @@ class Module extends EventEmitter {
|
|
|
1869
1871
|
}
|
|
1870
1872
|
static sanitizeArgs(values, doubleQuote) {
|
|
1871
1873
|
const result = typeof values === 'string' ? [values] : values;
|
|
1872
|
-
const pattern = /[^\w+-.,/:@]/g;
|
|
1873
|
-
const sanitize = (value) => value.replace(pattern, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
1874
1874
|
for (let i = 0; i < result.length; ++i) {
|
|
1875
1875
|
let value = result[i].trim(), leading = '';
|
|
1876
1876
|
if (value !== '--') {
|
|
1877
|
-
const opt =
|
|
1877
|
+
const opt = REGEXP_CLIOPTION.exec(value);
|
|
1878
1878
|
if (opt) {
|
|
1879
1879
|
if (!opt[2] && !opt[3]) {
|
|
1880
1880
|
result[i] = opt[1];
|
|
@@ -1884,7 +1884,7 @@ class Module extends EventEmitter {
|
|
|
1884
1884
|
value = opt[3];
|
|
1885
1885
|
}
|
|
1886
1886
|
if (value) {
|
|
1887
|
-
const quoted = /^(["'])(.*)\1
|
|
1887
|
+
const quoted = /^(["'])(.*)\1$/s.exec(value);
|
|
1888
1888
|
if (PLATFORM_WIN32) {
|
|
1889
1889
|
if (quoted) {
|
|
1890
1890
|
if (quoted[1] === '"') {
|
|
@@ -1897,33 +1897,19 @@ class Module extends EventEmitter {
|
|
|
1897
1897
|
value = wrapQuote(value);
|
|
1898
1898
|
}
|
|
1899
1899
|
}
|
|
1900
|
-
else {
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
if (quoted[1] === "'") {
|
|
1904
|
-
result[i] = leading + value;
|
|
1905
|
-
continue;
|
|
1906
|
-
}
|
|
1907
|
-
value = quoted[2];
|
|
1908
|
-
type = true;
|
|
1909
|
-
}
|
|
1910
|
-
if (pattern.test(value)) {
|
|
1911
|
-
if (type) {
|
|
1912
|
-
value = '"' + sanitize(value) + '"';
|
|
1913
|
-
}
|
|
1914
|
-
else {
|
|
1915
|
-
value = "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1916
|
-
}
|
|
1900
|
+
else if (!quoted) {
|
|
1901
|
+
if (REGEXP_CLIESCAPE.test(value)) {
|
|
1902
|
+
value = doubleQuote ? `"${value.replace(/(?<!\\)"/g, '\\"')}"` : `'${value.replace(/'/g, "'\\''")}'`;
|
|
1917
1903
|
}
|
|
1918
1904
|
else if (RESERVED_SHELL.includes(value)) {
|
|
1919
|
-
value =
|
|
1905
|
+
value = `'${value}'`;
|
|
1920
1906
|
}
|
|
1921
1907
|
}
|
|
1922
1908
|
}
|
|
1923
1909
|
else if (opt) {
|
|
1924
1910
|
leading = leading.trim();
|
|
1925
1911
|
if (!PLATFORM_WIN32 && leading.length > 2 && leading[1] !== '-') {
|
|
1926
|
-
leading
|
|
1912
|
+
leading.replace(REGEXP_CLIESCAPE, capture => '\\' + capture);
|
|
1927
1913
|
}
|
|
1928
1914
|
}
|
|
1929
1915
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.6.
|
|
23
|
+
"@e-mc/types": "0.6.15",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|