ses 1.14.0 → 2.0.0
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/README.md +2 -2
- package/dist/lockdown.cjs +770 -482
- package/dist/lockdown.mjs +770 -482
- package/dist/lockdown.umd.js +770 -482
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses-hermes.cjs +770 -482
- package/dist/ses.cjs +770 -482
- package/dist/ses.mjs +770 -482
- package/dist/ses.umd.js +770 -482
- package/dist/ses.umd.min.js +1 -1
- package/dist/types.d.cts +110 -141
- package/package.json +16 -23
- package/src/assert-shim.js +2 -2
- package/src/commons.js +103 -40
- package/src/enablements.js +18 -18
- package/src/error/assert.js +124 -99
- package/src/error/stringify-utils.js +2 -2
- package/src/error/tame-v8-error-constructor.js +15 -12
- package/src/error/types.js +1 -1
- package/src/get-anonymous-intrinsics.js +2 -3
- package/src/lockdown.js +36 -12
- package/src/module-instance.js +22 -18
- package/src/module-load.js +4 -4
- package/src/permits.js +18 -4
- package/src/reporting.js +48 -12
- package/src/scope-constants.js +17 -23
- package/src/tame-nan-sidechannel.js +103 -0
- package/src/transforms.js +9 -7
- package/types.d.ts +110 -141
- package/src/error/README.md +0 -99
package/src/module-instance.js
CHANGED
|
@@ -354,6 +354,25 @@ export const makeModuleInstance = (
|
|
|
354
354
|
};
|
|
355
355
|
notifiers['*'] = notifyStar;
|
|
356
356
|
|
|
357
|
+
const wireUpExportNotifier = (exportName, notify) => {
|
|
358
|
+
if (!notifiers[exportName] && notify !== false) {
|
|
359
|
+
notifiers[exportName] = notify;
|
|
360
|
+
|
|
361
|
+
// exported live binding state
|
|
362
|
+
let value;
|
|
363
|
+
const update = newValue => (value = newValue);
|
|
364
|
+
notify(update);
|
|
365
|
+
exportsProps[exportName] = {
|
|
366
|
+
get() {
|
|
367
|
+
return value;
|
|
368
|
+
},
|
|
369
|
+
set: undefined,
|
|
370
|
+
enumerable: true,
|
|
371
|
+
configurable: false,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
357
376
|
// Per the calling convention for the moduleFunctor generated from
|
|
358
377
|
// an ESM, the `imports` function gets called once up front
|
|
359
378
|
// to populate or arrange the population of imports and reexports.
|
|
@@ -407,30 +426,15 @@ export const makeModuleInstance = (
|
|
|
407
426
|
}
|
|
408
427
|
}
|
|
409
428
|
if (reexportMap[specifier]) {
|
|
410
|
-
//
|
|
429
|
+
// Set up reexport notifiers instantly so they are available in cycles.
|
|
411
430
|
for (const [localName, exportedName] of reexportMap[specifier]) {
|
|
412
|
-
|
|
431
|
+
wireUpExportNotifier(exportedName, importNotifiers[localName]);
|
|
413
432
|
}
|
|
414
433
|
}
|
|
415
434
|
}
|
|
416
435
|
|
|
417
436
|
for (const [exportName, notify] of entries(candidateAll)) {
|
|
418
|
-
|
|
419
|
-
notifiers[exportName] = notify;
|
|
420
|
-
|
|
421
|
-
// exported live binding state
|
|
422
|
-
let value;
|
|
423
|
-
const update = newValue => (value = newValue);
|
|
424
|
-
notify(update);
|
|
425
|
-
exportsProps[exportName] = {
|
|
426
|
-
get() {
|
|
427
|
-
return value;
|
|
428
|
-
},
|
|
429
|
-
set: undefined,
|
|
430
|
-
enumerable: true,
|
|
431
|
-
configurable: false,
|
|
432
|
-
};
|
|
433
|
-
}
|
|
437
|
+
wireUpExportNotifier(exportName, notify);
|
|
434
438
|
}
|
|
435
439
|
|
|
436
440
|
// Sort the module exports namespace as per spec.
|
package/src/module-load.js
CHANGED
|
@@ -510,7 +510,7 @@ const memoizedLoadWithErrorAnnotation = (
|
|
|
510
510
|
/**
|
|
511
511
|
* If `aggregateErrors` is `false`, the `errors` property of the fulfilled object
|
|
512
512
|
* will always be empty.
|
|
513
|
-
* @param {{errors?: Error[], noAggregateErrors?: boolean}} [options]
|
|
513
|
+
* @param {{errors?: Error[], noAggregateErrors?: boolean | undefined}} [options]
|
|
514
514
|
*/
|
|
515
515
|
const asyncJobQueue = ({ errors = [], noAggregateErrors = false } = {}) => {
|
|
516
516
|
/** @type {Set<Promise<undefined>>} */
|
|
@@ -552,7 +552,7 @@ const asyncJobQueue = ({ errors = [], noAggregateErrors = false } = {}) => {
|
|
|
552
552
|
/**
|
|
553
553
|
* If `aggregateErrors` is `false`, the `errors` property of the returned object
|
|
554
554
|
* will always be empty.
|
|
555
|
-
* @param {{errors?: Error[], noAggregateErrors?: boolean}} [options]
|
|
555
|
+
* @param {{errors?: Error[], noAggregateErrors?: boolean | undefined}} [options]
|
|
556
556
|
*/
|
|
557
557
|
const syncJobQueue = ({ errors = [], noAggregateErrors = false } = {}) => {
|
|
558
558
|
let current = [];
|
|
@@ -625,7 +625,7 @@ const preferAsync = (asyncImpl, _syncImpl) => asyncImpl;
|
|
|
625
625
|
* @param {WeakMap<object, object>} moduleAliases
|
|
626
626
|
* @param {Compartment} compartment
|
|
627
627
|
* @param {string} moduleSpecifier - The module specifier to load.
|
|
628
|
-
* @param {{ noAggregateErrors?: boolean}} options
|
|
628
|
+
* @param {{ noAggregateErrors?: boolean | undefined}} options
|
|
629
629
|
*/
|
|
630
630
|
export const load = async (
|
|
631
631
|
compartmentPrivateFields,
|
|
@@ -676,7 +676,7 @@ export const load = async (
|
|
|
676
676
|
* @param {WeakMap<object, object>} moduleAliases
|
|
677
677
|
* @param {Compartment} compartment
|
|
678
678
|
* @param {string} moduleSpecifier - The module specifier to load.
|
|
679
|
-
* @param {{ noAggregateErrors?: boolean}} options
|
|
679
|
+
* @param {{ noAggregateErrors?: boolean | undefined}} options
|
|
680
680
|
*/
|
|
681
681
|
|
|
682
682
|
export const loadNow = (
|
package/src/permits.js
CHANGED
|
@@ -59,10 +59,7 @@ export const universalPropertyNames = {
|
|
|
59
59
|
Boolean: 'Boolean',
|
|
60
60
|
DataView: 'DataView',
|
|
61
61
|
EvalError: 'EvalError',
|
|
62
|
-
|
|
63
|
-
Float16Array: 'Float16Array',
|
|
64
|
-
Float32Array: 'Float32Array',
|
|
65
|
-
Float64Array: 'Float64Array',
|
|
62
|
+
|
|
66
63
|
Int8Array: 'Int8Array',
|
|
67
64
|
Int16Array: 'Int16Array',
|
|
68
65
|
Int32Array: 'Int32Array',
|
|
@@ -144,6 +141,18 @@ export const initialGlobalPropertyNames = {
|
|
|
144
141
|
|
|
145
142
|
Math: '%InitialMath%',
|
|
146
143
|
|
|
144
|
+
// We move these from universalPropertyNames because the NaN side channel
|
|
145
|
+
// means that they are not quite harmless.
|
|
146
|
+
// We move them to initialGlobalPropertyNames so that they'll still be
|
|
147
|
+
// included in the primordials, repaired, and hardened. Thus, they
|
|
148
|
+
// can be endowed into compartments without hazard beyond the
|
|
149
|
+
// NaN side channel.
|
|
150
|
+
//
|
|
151
|
+
// // https://github.com/tc39/proposal-float16array
|
|
152
|
+
Float16Array: 'Float16Array',
|
|
153
|
+
Float32Array: 'Float32Array',
|
|
154
|
+
Float64Array: 'Float64Array',
|
|
155
|
+
|
|
147
156
|
// ESNext
|
|
148
157
|
|
|
149
158
|
// From Error-stack proposal
|
|
@@ -507,6 +516,11 @@ export const permitted = {
|
|
|
507
516
|
seal: fn,
|
|
508
517
|
setPrototypeOf: fn,
|
|
509
518
|
values: fn,
|
|
519
|
+
'RegisteredSymbol(harden)': {
|
|
520
|
+
...fn,
|
|
521
|
+
// Installed with hardenTaming: 'unsafe'
|
|
522
|
+
isFake: 'boolean',
|
|
523
|
+
},
|
|
510
524
|
// https://github.com/tc39/proposal-accessible-object-hasownproperty
|
|
511
525
|
hasOwn: fn,
|
|
512
526
|
// https://github.com/tc39/proposal-array-grouping
|
package/src/reporting.js
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { globalThis } from './commons.js';
|
|
2
2
|
import { assert } from './error/assert.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @import {Reporter, GroupReporter} from './reporting-types.js'
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/* eslint-disable @endo/no-polymorphic-call */
|
|
9
|
+
/**
|
|
10
|
+
* To address https://github.com/endojs/endo/issues/2908,
|
|
11
|
+
* the `consoleReporter` uses the current `console` rather
|
|
12
|
+
* than the original one.
|
|
13
|
+
*
|
|
14
|
+
* @type {GroupReporter}
|
|
15
|
+
*/
|
|
16
|
+
const consoleReporter = {
|
|
17
|
+
warn(...args) {
|
|
18
|
+
globalThis.console.warn(...args);
|
|
19
|
+
},
|
|
20
|
+
error(...args) {
|
|
21
|
+
globalThis.console.error(...args);
|
|
22
|
+
},
|
|
23
|
+
...(globalThis.console?.groupCollapsed
|
|
24
|
+
? {
|
|
25
|
+
groupCollapsed(...args) {
|
|
26
|
+
globalThis.console.groupCollapsed(...args);
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
: undefined),
|
|
30
|
+
...(globalThis.console?.groupEnd
|
|
31
|
+
? {
|
|
32
|
+
groupEnd() {
|
|
33
|
+
globalThis.console.groupEnd();
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: undefined),
|
|
37
|
+
};
|
|
38
|
+
/* eslint-enable @endo/no-polymorphic-call */
|
|
39
|
+
|
|
8
40
|
/**
|
|
9
41
|
* Creates a suitable reporter for internal errors and warnings out of the
|
|
10
|
-
* Node.js console.error to ensure all messages to
|
|
42
|
+
* Node.js console.error to ensure all messages go to stderr, including the
|
|
11
43
|
* group label.
|
|
12
44
|
* Accounts for the extra space introduced by console.error as a delimiter
|
|
13
45
|
* between the indent and subsequent arguments.
|
|
@@ -51,18 +83,22 @@ export const chooseReporter = reporting => {
|
|
|
51
83
|
if (reporting === 'none') {
|
|
52
84
|
return makeReportPrinter(mute);
|
|
53
85
|
}
|
|
54
|
-
if (
|
|
55
|
-
reporting === 'console' ||
|
|
56
|
-
globalThis.window === globalThis ||
|
|
57
|
-
globalThis.importScripts !== undefined
|
|
58
|
-
) {
|
|
59
|
-
return console;
|
|
60
|
-
}
|
|
61
86
|
if (globalThis.console !== undefined) {
|
|
87
|
+
if (
|
|
88
|
+
reporting === 'console' || // asks for console explicitly
|
|
89
|
+
globalThis.window === globalThis || // likely on browser
|
|
90
|
+
globalThis.importScripts !== undefined // likely on worker
|
|
91
|
+
) {
|
|
92
|
+
// reporter just delegates directly to the current console
|
|
93
|
+
return consoleReporter;
|
|
94
|
+
}
|
|
95
|
+
assert(reporting === 'platform');
|
|
62
96
|
// On Node.js, we send all feedback to stderr, regardless of purported level.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
97
|
+
// This uses `consoleReporter.error` instead of `console.error` because we
|
|
98
|
+
// want the constructed reporter to use the `console.error` of the current
|
|
99
|
+
// `console`, not the `console` that was installed when the reporter
|
|
100
|
+
// was created.
|
|
101
|
+
return makeReportPrinter(consoleReporter.error);
|
|
66
102
|
}
|
|
67
103
|
if (globalThis.print !== undefined) {
|
|
68
104
|
return makeReportPrinter(globalThis.print);
|
package/src/scope-constants.js
CHANGED
|
@@ -4,15 +4,18 @@ import {
|
|
|
4
4
|
getOwnPropertyDescriptor,
|
|
5
5
|
getOwnPropertyNames,
|
|
6
6
|
hasOwn,
|
|
7
|
-
|
|
7
|
+
regexpExec,
|
|
8
|
+
Set,
|
|
9
|
+
setHas,
|
|
8
10
|
} from './commons.js';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
* In JavaScript you cannot use
|
|
13
|
-
*
|
|
13
|
+
* reservedNames
|
|
14
|
+
* In JavaScript you cannot use reserved words as variable names (except for
|
|
15
|
+
* "eval", which is specially reserved to prevent shadowing).
|
|
16
|
+
* https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-identifier-names
|
|
14
17
|
*/
|
|
15
|
-
const
|
|
18
|
+
const reservedNames = new Set([
|
|
16
19
|
// 11.6.2.1 Keywords
|
|
17
20
|
'await',
|
|
18
21
|
'break',
|
|
@@ -73,7 +76,10 @@ const keywords = [
|
|
|
73
76
|
|
|
74
77
|
'this',
|
|
75
78
|
'arguments',
|
|
76
|
-
|
|
79
|
+
|
|
80
|
+
// Reserved by us
|
|
81
|
+
'eval',
|
|
82
|
+
]);
|
|
77
83
|
|
|
78
84
|
/**
|
|
79
85
|
* identifierPattern
|
|
@@ -89,24 +95,12 @@ const identifierPattern = /^[a-zA-Z_$][\w$]*$/;
|
|
|
89
95
|
|
|
90
96
|
/**
|
|
91
97
|
* isValidIdentifierName()
|
|
92
|
-
*
|
|
93
|
-
* property names which can be variable names, including the names
|
|
94
|
-
* of inherited properties. It excludes symbols and names which are
|
|
95
|
-
* keywords. We drop symbols safely. Currently, this shim refuses
|
|
96
|
-
* service if any of the names are keywords or keyword-like. This is
|
|
97
|
-
* safe and only prevent performance optimization.
|
|
98
|
+
* Is a value allowed as an arbitrary identifier name?
|
|
98
99
|
*
|
|
99
100
|
* @param {string} name
|
|
100
101
|
*/
|
|
101
|
-
export const isValidIdentifierName = name =>
|
|
102
|
-
|
|
103
|
-
// /../.test() to guard against the case where RegExp has been poisoned.
|
|
104
|
-
return (
|
|
105
|
-
name !== 'eval' &&
|
|
106
|
-
!arrayIncludes(keywords, name) &&
|
|
107
|
-
regexpTest(identifierPattern, name)
|
|
108
|
-
);
|
|
109
|
-
};
|
|
102
|
+
export const isValidIdentifierName = name =>
|
|
103
|
+
!setHas(reservedNames, name) && !!regexpExec(identifierPattern, name);
|
|
110
104
|
|
|
111
105
|
/*
|
|
112
106
|
* isImmutableDataProperty
|
|
@@ -137,12 +131,12 @@ function isImmutableDataProperty(obj, name) {
|
|
|
137
131
|
|
|
138
132
|
/**
|
|
139
133
|
* getScopeConstants()
|
|
140
|
-
* What variable names might
|
|
134
|
+
* What variable names might be brought into scope? These include all
|
|
141
135
|
* property names which can be variable names, including the names
|
|
142
136
|
* of inherited properties. It excludes symbols and names which are
|
|
143
137
|
* keywords. We drop symbols safely. Currently, this shim refuses
|
|
144
138
|
* service if any of the names are keywords or keyword-like. This is
|
|
145
|
-
* safe and only
|
|
139
|
+
* safe and only affects performance optimization.
|
|
146
140
|
*
|
|
147
141
|
* @param {object} globalObject
|
|
148
142
|
* @param {object} moduleLexicals
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Object, DataView, Reflect, Number } from './commons.js';
|
|
2
|
+
|
|
3
|
+
const { is, defineProperty, entries } = Object;
|
|
4
|
+
const { apply } = Reflect;
|
|
5
|
+
|
|
6
|
+
const { prototype: dataViewPrototype } = DataView;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* These `FERAL*` methods open up the NaN side-channel on some platforms,
|
|
10
|
+
* like v8. Thus, we need to encapsulate them and replace them with wrappers
|
|
11
|
+
* that canonicaize NaNs.
|
|
12
|
+
*/
|
|
13
|
+
const {
|
|
14
|
+
setFloat16: FERAL_SET_FLOAT16,
|
|
15
|
+
setFloat32: FERAL_SET_FLOAT32,
|
|
16
|
+
setFloat64: FERAL_SET_FLOAT64,
|
|
17
|
+
|
|
18
|
+
setUint16,
|
|
19
|
+
setUint32,
|
|
20
|
+
setBigUint64,
|
|
21
|
+
} = dataViewPrototype;
|
|
22
|
+
|
|
23
|
+
// See https://webidl.spec.whatwg.org/#js-unrestricted-double which implies
|
|
24
|
+
// that this is the canonical NaN for web standards.
|
|
25
|
+
// Casual googling stongly suggests that this is also the cosmWasm
|
|
26
|
+
// canonical NaN. But I have not yet found an authoritative page stating this.
|
|
27
|
+
const canonicalNaN = 0x7ff8000000000000n;
|
|
28
|
+
|
|
29
|
+
// Use method shorthand syntax to be this-sensitive but now be constructable
|
|
30
|
+
// nor have a `prototype` property.
|
|
31
|
+
const methods = {
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} byteOffset
|
|
34
|
+
* @param {number} value
|
|
35
|
+
* @param {boolean} [littleEndian]
|
|
36
|
+
*/
|
|
37
|
+
setFloat16(byteOffset, value, littleEndian = undefined) {
|
|
38
|
+
if (is(value, NaN)) {
|
|
39
|
+
return apply(setUint16, this, [
|
|
40
|
+
byteOffset,
|
|
41
|
+
Number(canonicalNaN),
|
|
42
|
+
littleEndian,
|
|
43
|
+
]);
|
|
44
|
+
} else {
|
|
45
|
+
return apply(FERAL_SET_FLOAT16, this, [byteOffset, value, littleEndian]);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* @param {number} byteOffset
|
|
50
|
+
* @param {number} value
|
|
51
|
+
* @param {boolean} [littleEndian]
|
|
52
|
+
*/
|
|
53
|
+
setFloat32(byteOffset, value, littleEndian = undefined) {
|
|
54
|
+
if (is(value, NaN)) {
|
|
55
|
+
return apply(setUint32, this, [
|
|
56
|
+
byteOffset,
|
|
57
|
+
Number(canonicalNaN),
|
|
58
|
+
littleEndian,
|
|
59
|
+
]);
|
|
60
|
+
} else {
|
|
61
|
+
return apply(FERAL_SET_FLOAT32, this, [byteOffset, value, littleEndian]);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* @param {number} byteOffset
|
|
66
|
+
* @param {number} value
|
|
67
|
+
* @param {boolean} [littleEndian]
|
|
68
|
+
*/
|
|
69
|
+
setFloat64(byteOffset, value, littleEndian = undefined) {
|
|
70
|
+
if (is(value, NaN)) {
|
|
71
|
+
return apply(setBigUint64, this, [
|
|
72
|
+
byteOffset,
|
|
73
|
+
canonicalNaN,
|
|
74
|
+
littleEndian,
|
|
75
|
+
]);
|
|
76
|
+
} else {
|
|
77
|
+
return apply(FERAL_SET_FLOAT64, this, [byteOffset, value, littleEndian]);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Replaces the dangerous `setFloat*` methods on `DataView.prototype`
|
|
84
|
+
* with safe wrappers that first canonicalize NaNs before calling the
|
|
85
|
+
* original hidden methods.
|
|
86
|
+
* By itself, this does not make us safe against the NaN side channel.
|
|
87
|
+
* Separately, we do not include the `Float*Array` constructors on the
|
|
88
|
+
* list of universal safe globals. Thus, constructed compartments do not
|
|
89
|
+
* get these by default.
|
|
90
|
+
*
|
|
91
|
+
* These replacement `setFloat*` methods canonicalize NaN, but they
|
|
92
|
+
* do not canonicalize `-0` to `0`. If callers wish to do so, they should do
|
|
93
|
+
* it themselves before calling these
|
|
94
|
+
*/
|
|
95
|
+
export const tameNaNSideChannel = () => {
|
|
96
|
+
for (const [name, method] of entries(methods)) {
|
|
97
|
+
defineProperty(dataViewPrototype, name, {
|
|
98
|
+
// Since we're redefining properties that already exist, by omitting the
|
|
99
|
+
// other descriptor attributes here, they are unchanged.
|
|
100
|
+
value: method,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
package/src/transforms.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import {
|
|
4
4
|
FERAL_REG_EXP,
|
|
5
5
|
SyntaxError,
|
|
6
|
-
|
|
6
|
+
regexpReplace,
|
|
7
|
+
sealRegexp,
|
|
7
8
|
stringSearch,
|
|
8
9
|
stringSlice,
|
|
9
10
|
stringSplit,
|
|
@@ -35,7 +36,9 @@ function getLineNumber(src, pattern) {
|
|
|
35
36
|
|
|
36
37
|
// /////////////////////////////////////////////////////////////////////////////
|
|
37
38
|
|
|
38
|
-
const htmlCommentPattern =
|
|
39
|
+
const htmlCommentPattern = sealRegexp(
|
|
40
|
+
new FERAL_REG_EXP(`(?:${'<'}!--|--${'>'})`, 'g'),
|
|
41
|
+
);
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* Conservatively reject the source text if it may contain text that some
|
|
@@ -100,14 +103,13 @@ export const rejectHtmlComments = src => {
|
|
|
100
103
|
*/
|
|
101
104
|
export const evadeHtmlCommentTest = src => {
|
|
102
105
|
const replaceFn = match => (match[0] === '<' ? '< ! --' : '-- >');
|
|
103
|
-
return
|
|
106
|
+
return regexpReplace(htmlCommentPattern, src, replaceFn);
|
|
104
107
|
};
|
|
105
108
|
|
|
106
109
|
// /////////////////////////////////////////////////////////////////////////////
|
|
107
110
|
|
|
108
|
-
const importPattern =
|
|
109
|
-
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
110
|
-
'g',
|
|
111
|
+
const importPattern = sealRegexp(
|
|
112
|
+
new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))', 'g'),
|
|
111
113
|
);
|
|
112
114
|
|
|
113
115
|
/**
|
|
@@ -170,7 +172,7 @@ export const rejectImportExpressions = src => {
|
|
|
170
172
|
*/
|
|
171
173
|
export const evadeImportExpressionTest = src => {
|
|
172
174
|
const replaceFn = (_, p1, p2) => `${p1}__import__${p2}`;
|
|
173
|
-
return
|
|
175
|
+
return regexpReplace(importPattern, src, replaceFn);
|
|
174
176
|
};
|
|
175
177
|
|
|
176
178
|
// /////////////////////////////////////////////////////////////////////////////
|