@e-mc/module 0.3.1 → 0.3.3

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/LICENSE CHANGED
@@ -1,11 +1,11 @@
1
- Copyright 2023 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
1
+ Copyright 2023 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
11
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ModuleConstructor } from '../types/lib';
2
-
3
- declare const Module: ModuleConstructor;
4
-
1
+ import type { ModuleConstructor } from '../types/lib';
2
+
3
+ declare const Module: ModuleConstructor;
4
+
5
5
  export = Module;
package/index.js CHANGED
@@ -117,8 +117,6 @@ const VALUES = {
117
117
  ["broadcast.out" /* KEY_NAME.BROADCAST_OUT */]: null,
118
118
  ["logger.level" /* KEY_NAME.LOGGER_LEVEL */]: -1
119
119
  };
120
- const REGEXP_SHELLOPT = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/;
121
- const REGEXP_SHELLVAL = /[^0-9a-z%+-./:=@_]/gi;
122
120
  const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
123
121
  let LOG_NEWLINE = true;
124
122
  let LOG_EMPTYLINE = false;
@@ -1003,7 +1001,7 @@ class Module extends EventEmitter {
1003
1001
  }
1004
1002
  }
1005
1003
  }
1006
- if (external && !pathname && VALUES["node.require.npm" /* KEY_NAME.NODE_REQUIRE_NPM */] && location.length <= 214 && /^(?:@(?:[a-z\d-*~][a-z\d-*._~]*\/)+)?[a-z\d-~][a-z\d-._~]*$/.test(location)) {
1004
+ if (external && !pathname && VALUES["node.require.npm" /* KEY_NAME.NODE_REQUIRE_NPM */] && /^(?:@[a-z\d-*~][a-z\d-*._~]*\/)?[a-z\d-~][a-z\d-._~]*(?:\/.*)?$/.test(location)) {
1007
1005
  try {
1008
1006
  // @ts-ignore
1009
1007
  result = checkFunction(require(types_1.IMPORT_MAP[location] || location));
@@ -1846,12 +1844,12 @@ class Module extends EventEmitter {
1846
1844
  }
1847
1845
  static sanitizeArgs(values, doubleQuote) {
1848
1846
  const result = typeof values === 'string' ? [values] : values;
1849
- const pattern = /^(["'])(.*)\1$/;
1850
- const sanitize = (value) => value.replace(REGEXP_SHELLVAL, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
1847
+ const pattern = /[^0-9a-z%+-./:=@_]/gi;
1848
+ const sanitize = (value) => value.replace(pattern, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
1851
1849
  for (let i = 0; i < result.length; ++i) {
1852
1850
  let value = result[i].trim(), leading = '';
1853
1851
  if (value !== '--') {
1854
- const opt = REGEXP_SHELLOPT.exec(value);
1852
+ const opt = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/.exec(value);
1855
1853
  if (opt) {
1856
1854
  if (!opt[2] && !opt[3]) {
1857
1855
  result[i] = opt[1];
@@ -1861,7 +1859,7 @@ class Module extends EventEmitter {
1861
1859
  value = opt[3];
1862
1860
  }
1863
1861
  if (value) {
1864
- const quoted = pattern.exec(value);
1862
+ const quoted = /^(["'])(.*)\1$/.exec(value);
1865
1863
  if (PLATFORM_WIN32) {
1866
1864
  if (quoted) {
1867
1865
  if (quoted[1] === '"') {
@@ -1884,7 +1882,7 @@ class Module extends EventEmitter {
1884
1882
  value = quoted[2];
1885
1883
  type = true;
1886
1884
  }
1887
- if (REGEXP_SHELLVAL.test(value)) {
1885
+ if (pattern.test(value)) {
1888
1886
  if (type) {
1889
1887
  value = '"' + sanitize(value) + '"';
1890
1888
  }
package/lib-v4.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { IModuleLibV4 } from '../types/lib/compat-v4';
2
-
3
- declare const LibV4: IModuleLibV4;
4
-
1
+ import type { IModuleLibV4 } from '../types/lib/compat-v4';
2
+
3
+ declare const LibV4: IModuleLibV4;
4
+
5
5
  export = LibV4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
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": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.3.1",
23
+ "@e-mc/types": "0.3.3",
24
24
  "abort-controller": "^3.0.0",
25
25
  "chalk": "4.1.2",
26
26
  "event-target-shim": "^5.0.1",