@e-mc/module 0.3.0 → 0.3.2

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.
Files changed (2) hide show
  1. package/index.js +6 -8
  2. package/package.json +2 -2
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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.0",
23
+ "@e-mc/types": "0.3.2",
24
24
  "abort-controller": "^3.0.0",
25
25
  "chalk": "4.1.2",
26
26
  "event-target-shim": "^5.0.1",