poe-code 14.0.53 → 14.0.55
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/dist/index.js +73 -25
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-VDFW3EKS.js → chunk-6LFWVA64.js} +71 -26
- package/packages/safe-js/dist/chunks/{chunk-VDFW3EKS.js.map → chunk-6LFWVA64.js.map} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-4XYGVCOQ.js → chunk-G5LQ37D4.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/globals/regex.d.ts +5 -2
- package/packages/safe-js/dist/interp/globals/regex.js +26 -12
- package/packages/safe-js/dist/interp/globals.js +1 -1
- package/packages/safe-js/dist/interp/interpreter.js +1 -1
- package/packages/safe-js/dist/interp/methods/string.d.ts +2 -2
- package/packages/safe-js/dist/interp/methods/string.js +40 -6
- /package/packages/safe-js/dist/chunks/{chunk-4XYGVCOQ.js.map → chunk-G5LQ37D4.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -145153,14 +145153,28 @@ function getStringMember(value, property, budget) {
|
|
|
145153
145153
|
name: `String#${property}`,
|
|
145154
145154
|
...property === "localeCompare" ? { length: 1 } : {},
|
|
145155
145155
|
...property === "isWellFormed" || property === "toWellFormed" ? { length: 0 } : {},
|
|
145156
|
-
call: (args, context) =>
|
|
145157
|
-
|
|
145158
|
-
|
|
145159
|
-
|
|
145160
|
-
|
|
145161
|
-
|
|
145162
|
-
|
|
145163
|
-
|
|
145156
|
+
call: async (args, context) => {
|
|
145157
|
+
const receiver = context?.thisValue;
|
|
145158
|
+
if (receiver === null || receiver === void 0) {
|
|
145159
|
+
throw new TypeError(`String#${property} requires a non-null receiver.`);
|
|
145160
|
+
}
|
|
145161
|
+
const retainedReceiver = {};
|
|
145162
|
+
budget.setRetainedValues(retainedReceiver, () => [receiver]);
|
|
145163
|
+
try {
|
|
145164
|
+
const string = await sandboxString(receiver, budget, context);
|
|
145165
|
+
return await callStringMethod(
|
|
145166
|
+
string,
|
|
145167
|
+
property,
|
|
145168
|
+
args,
|
|
145169
|
+
budget,
|
|
145170
|
+
(closure, closureArgs) => invokeBuiltinClosure(closure, closureArgs, budget, context, void 0),
|
|
145171
|
+
context?.compilation,
|
|
145172
|
+
context
|
|
145173
|
+
);
|
|
145174
|
+
} finally {
|
|
145175
|
+
budget.setRetainedValues(retainedReceiver, void 0);
|
|
145176
|
+
}
|
|
145177
|
+
}
|
|
145164
145178
|
});
|
|
145165
145179
|
}
|
|
145166
145180
|
function getStringIndex(property) {
|
|
@@ -145175,7 +145189,7 @@ function isStringMethodName(property) {
|
|
|
145175
145189
|
}
|
|
145176
145190
|
function validateStringMethodArguments(_methodName, _args) {
|
|
145177
145191
|
}
|
|
145178
|
-
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent) {
|
|
145192
|
+
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
|
|
145179
145193
|
if (methodName === "isWellFormed") {
|
|
145180
145194
|
for (let index = 0; index < value.length; index++) {
|
|
145181
145195
|
const codeUnit = value.charCodeAt(index);
|
|
@@ -145214,6 +145228,9 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
145214
145228
|
if (methodName === "replace" || methodName === "replaceAll") {
|
|
145215
145229
|
return callReplaceLikeMethod(value, methodName, args, budget, callClosure);
|
|
145216
145230
|
}
|
|
145231
|
+
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
145232
|
+
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
145233
|
+
}
|
|
145217
145234
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
145218
145235
|
const compilation = new CompileScope(operation.owner);
|
|
145219
145236
|
try {
|
|
@@ -145484,6 +145501,21 @@ function callSplit(value, args, budget, compilation) {
|
|
|
145484
145501
|
budget.allocateArrayLength(result.length);
|
|
145485
145502
|
return result;
|
|
145486
145503
|
}
|
|
145504
|
+
async function callStringPattern(value, methodName, pattern, budget, parent, context) {
|
|
145505
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
145506
|
+
const compilation = new CompileScope(operation.owner);
|
|
145507
|
+
const retainedPattern = {};
|
|
145508
|
+
budget.setRetainedValues(retainedPattern, () => [pattern]);
|
|
145509
|
+
try {
|
|
145510
|
+
const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
|
|
145511
|
+
const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
|
|
145512
|
+
return callMatchLikeMethod(value, methodName, [regex], compilation);
|
|
145513
|
+
} finally {
|
|
145514
|
+
budget.setRetainedValues(retainedPattern, void 0);
|
|
145515
|
+
compilation.dispose();
|
|
145516
|
+
operation.release();
|
|
145517
|
+
}
|
|
145518
|
+
}
|
|
145487
145519
|
function callMatchLikeMethod(value, methodName, args, compilation) {
|
|
145488
145520
|
const regex = args[0];
|
|
145489
145521
|
if (!isSandboxRegex(regex))
|
|
@@ -145501,15 +145533,16 @@ function callMatchLikeMethod(value, methodName, args, compilation) {
|
|
|
145501
145533
|
return toMatchArray(executeRegex(regex, value), value);
|
|
145502
145534
|
if (methodName === "match") regex.lastIndex = 0;
|
|
145503
145535
|
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
|
|
145504
|
-
const matches = collectRegexMatches(matcher, value, true);
|
|
145536
|
+
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget);
|
|
145505
145537
|
if (methodName === "match" && matches.length === 0) return null;
|
|
145506
145538
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
145507
145539
|
}
|
|
145508
|
-
function collectRegexMatches(regex, value, all) {
|
|
145540
|
+
function collectRegexMatches(regex, value, all, budget) {
|
|
145509
145541
|
const matches = [];
|
|
145510
145542
|
do {
|
|
145511
145543
|
const match = executeRegex(regex, value);
|
|
145512
145544
|
if (match === null) break;
|
|
145545
|
+
budget?.allocateArrayLength(matches.length + 1);
|
|
145513
145546
|
matches.push(match);
|
|
145514
145547
|
if (all && match.text.length === 0) regex.lastIndex += 1;
|
|
145515
145548
|
} while (all);
|
|
@@ -145532,7 +145565,9 @@ var SPLIT_STRING_MESSAGE, stringMethodNames;
|
|
|
145532
145565
|
var init_string = __esm({
|
|
145533
145566
|
"packages/safe-js/src/interp/methods/string.ts"() {
|
|
145534
145567
|
"use strict";
|
|
145568
|
+
init_builtin_call();
|
|
145535
145569
|
init_compile_guard();
|
|
145570
|
+
init_string_coercion();
|
|
145536
145571
|
init_values();
|
|
145537
145572
|
init_regex();
|
|
145538
145573
|
SPLIT_STRING_MESSAGE = "String#split only supports string separator values.";
|
|
@@ -148440,7 +148475,8 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
148440
148475
|
args.value,
|
|
148441
148476
|
context.budget,
|
|
148442
148477
|
(closure, closureArgs) => invokeSandboxClosure(closure, closureArgs, context, context.callStack),
|
|
148443
|
-
context.compilation
|
|
148478
|
+
context.compilation,
|
|
148479
|
+
createCoercionContext(context)
|
|
148444
148480
|
)
|
|
148445
148481
|
};
|
|
148446
148482
|
} catch (error3) {
|
|
@@ -150998,32 +151034,43 @@ var init_math = __esm({
|
|
|
150998
151034
|
});
|
|
150999
151035
|
|
|
151000
151036
|
// packages/safe-js/src/interp/globals/regex.ts
|
|
151001
|
-
function createRegexGlobals(
|
|
151002
|
-
const
|
|
151003
|
-
const selected =
|
|
151037
|
+
function createRegexGlobals(options) {
|
|
151038
|
+
const invoke2 = (construct) => async (args, context) => {
|
|
151039
|
+
const selected = options.compileOwner ?? context?.compilation?.owner;
|
|
151004
151040
|
if (context?.compilation?.owner !== void 0 && selected !== context.compilation.owner) {
|
|
151005
151041
|
throw new SandboxError("reentry");
|
|
151006
151042
|
}
|
|
151007
|
-
const operation =
|
|
151008
|
-
const compilation = context?.compilation
|
|
151043
|
+
const operation = options.budget.acquireCompileOwner(false, selected);
|
|
151044
|
+
const compilation = context?.compilation?.owner === operation.owner ? context.compilation : new CompileScope(operation.owner);
|
|
151045
|
+
let source = "";
|
|
151046
|
+
const retained = {};
|
|
151047
|
+
options.budget.setRetainedValues(retained, () => [...args, source]);
|
|
151009
151048
|
try {
|
|
151049
|
+
const pattern = args[0];
|
|
151050
|
+
const flags = args[1];
|
|
151051
|
+
if (!construct && isSandboxRegex(pattern) && flags === void 0) return pattern;
|
|
151052
|
+
const sourceValue = isSandboxRegex(pattern) ? pattern.source : pattern;
|
|
151053
|
+
const flagsValue = isSandboxRegex(pattern) && flags === void 0 ? pattern.flags : flags;
|
|
151054
|
+
source = sourceValue === void 0 ? "" : await sandboxString(sourceValue, options.budget, context);
|
|
151055
|
+
const flagText = flagsValue === void 0 ? "" : await sandboxString(flagsValue, options.budget, context);
|
|
151010
151056
|
const regex = createSandboxRegex(
|
|
151011
|
-
|
|
151012
|
-
|
|
151057
|
+
source,
|
|
151058
|
+
flagText,
|
|
151013
151059
|
0,
|
|
151014
151060
|
compilation
|
|
151015
151061
|
);
|
|
151016
|
-
if (
|
|
151017
|
-
reconcileCompiledValues(
|
|
151062
|
+
if (compilation !== context?.compilation) {
|
|
151063
|
+
reconcileCompiledValues(options.budget, [regex], compilation);
|
|
151018
151064
|
}
|
|
151019
151065
|
return regex;
|
|
151020
151066
|
} finally {
|
|
151021
|
-
|
|
151022
|
-
|
|
151067
|
+
options.budget.setRetainedValues(retained, void 0);
|
|
151068
|
+
if (compilation !== context?.compilation) compilation.dispose();
|
|
151069
|
+
operation.release();
|
|
151023
151070
|
}
|
|
151024
151071
|
};
|
|
151025
151072
|
return {
|
|
151026
|
-
RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call:
|
|
151073
|
+
RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: invoke2(false), construct: invoke2(true) })
|
|
151027
151074
|
};
|
|
151028
151075
|
}
|
|
151029
151076
|
var init_regex2 = __esm({
|
|
@@ -151032,6 +151079,7 @@ var init_regex2 = __esm({
|
|
|
151032
151079
|
init_values();
|
|
151033
151080
|
init_compile_guard();
|
|
151034
151081
|
init_budget2();
|
|
151082
|
+
init_string_coercion();
|
|
151035
151083
|
}
|
|
151036
151084
|
});
|
|
151037
151085
|
|
|
@@ -151615,7 +151663,7 @@ function createBuiltinBindings(options) {
|
|
|
151615
151663
|
...createObjectArrayGlobals(options),
|
|
151616
151664
|
...createMiscGlobals(options),
|
|
151617
151665
|
...createPromiseGlobals(options),
|
|
151618
|
-
...createRegexGlobals(options
|
|
151666
|
+
...createRegexGlobals(options)
|
|
151619
151667
|
};
|
|
151620
151668
|
}
|
|
151621
151669
|
var init_globals = __esm({
|