poe-code 14.0.54 → 14.0.56
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 +79 -22
- 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-Z55VACOY.js → chunk-SRYQTOX4.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-L7PHF62H.js → chunk-XI33TU4X.js} +76 -23
- package/packages/safe-js/dist/chunks/chunk-XI33TU4X.js.map +7 -0
- 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/regex.d.ts +3 -3
- package/packages/safe-js/dist/interp/methods/regex.js +32 -5
- package/packages/safe-js/dist/interp/methods/string.d.ts +2 -2
- package/packages/safe-js/dist/interp/methods/string.js +24 -4
- package/packages/safe-js/dist/chunks/chunk-L7PHF62H.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-Z55VACOY.js.map → chunk-SRYQTOX4.js.map} +0 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XI33TU4X.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-SRYQTOX4.js.map
|
|
@@ -8524,7 +8524,7 @@ function getRegexMember(target, property, budget) {
|
|
|
8524
8524
|
return createSandboxClosure({
|
|
8525
8525
|
sandbox: true,
|
|
8526
8526
|
name: `RegExp#${property}`,
|
|
8527
|
-
call: (args) => callRegexMethod(
|
|
8527
|
+
call: (args, context) => callRegexMethod(context?.thisValue, property, args, budget, context)
|
|
8528
8528
|
});
|
|
8529
8529
|
}
|
|
8530
8530
|
function escapeRegexSource(source, budget) {
|
|
@@ -8554,9 +8554,30 @@ function setRegexMember(target, property, value) {
|
|
|
8554
8554
|
}
|
|
8555
8555
|
target.lastIndex = Number(value);
|
|
8556
8556
|
}
|
|
8557
|
-
function callRegexMethod(target, methodName, args) {
|
|
8558
|
-
|
|
8559
|
-
|
|
8557
|
+
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
8558
|
+
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
8559
|
+
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
8560
|
+
}
|
|
8561
|
+
const retained = {};
|
|
8562
|
+
budget.setRetainedValues(retained, () => [target, ...args]);
|
|
8563
|
+
try {
|
|
8564
|
+
const input = await sandboxString(args[0], budget, context);
|
|
8565
|
+
if (methodName === "test") {
|
|
8566
|
+
const exec = context?.getProperty === void 0 ? getSandboxDataProperty(target, "exec", budget) : context.getProperty(target, "exec");
|
|
8567
|
+
if (isSandboxClosure(exec)) {
|
|
8568
|
+
const result = await invokeBuiltinClosure(exec, [input], budget, context, target);
|
|
8569
|
+
if (result !== null && typeof result !== "object") {
|
|
8570
|
+
throw new TypeError("RegExp#test exec must return an object or null.");
|
|
8571
|
+
}
|
|
8572
|
+
return result !== null;
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
if (!isSandboxRegex(target)) throw new TypeError("RegExp execution requires a regex receiver.");
|
|
8576
|
+
const match = executeRegex(target, input);
|
|
8577
|
+
return methodName === "test" ? match !== null : toMatchArray(match, input);
|
|
8578
|
+
} finally {
|
|
8579
|
+
budget.setRetainedValues(retained, void 0);
|
|
8580
|
+
}
|
|
8560
8581
|
}
|
|
8561
8582
|
function executeRegex(target, input) {
|
|
8562
8583
|
const pattern = getSandboxRegexPattern(target);
|
|
@@ -24950,7 +24971,8 @@ function getStringMember(value, property, budget) {
|
|
|
24950
24971
|
args,
|
|
24951
24972
|
budget,
|
|
24952
24973
|
(closure, closureArgs) => invokeBuiltinClosure(closure, closureArgs, budget, context, void 0),
|
|
24953
|
-
context?.compilation
|
|
24974
|
+
context?.compilation,
|
|
24975
|
+
context
|
|
24954
24976
|
);
|
|
24955
24977
|
} finally {
|
|
24956
24978
|
budget.setRetainedValues(retainedReceiver, void 0);
|
|
@@ -24970,7 +24992,7 @@ function isStringMethodName(property) {
|
|
|
24970
24992
|
}
|
|
24971
24993
|
function validateStringMethodArguments(_methodName, _args) {
|
|
24972
24994
|
}
|
|
24973
|
-
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent) {
|
|
24995
|
+
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
|
|
24974
24996
|
if (methodName === "isWellFormed") {
|
|
24975
24997
|
for (let index = 0; index < value.length; index++) {
|
|
24976
24998
|
const codeUnit = value.charCodeAt(index);
|
|
@@ -25009,6 +25031,9 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
25009
25031
|
if (methodName === "replace" || methodName === "replaceAll") {
|
|
25010
25032
|
return callReplaceLikeMethod(value, methodName, args, budget, callClosure);
|
|
25011
25033
|
}
|
|
25034
|
+
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
25035
|
+
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
25036
|
+
}
|
|
25012
25037
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25013
25038
|
const compilation = new CompileScope(operation.owner);
|
|
25014
25039
|
try {
|
|
@@ -25279,6 +25304,21 @@ function callSplit(value, args, budget, compilation) {
|
|
|
25279
25304
|
budget.allocateArrayLength(result.length);
|
|
25280
25305
|
return result;
|
|
25281
25306
|
}
|
|
25307
|
+
async function callStringPattern(value, methodName, pattern, budget, parent, context) {
|
|
25308
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25309
|
+
const compilation = new CompileScope(operation.owner);
|
|
25310
|
+
const retainedPattern = {};
|
|
25311
|
+
budget.setRetainedValues(retainedPattern, () => [pattern]);
|
|
25312
|
+
try {
|
|
25313
|
+
const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
|
|
25314
|
+
const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
|
|
25315
|
+
return callMatchLikeMethod(value, methodName, [regex], compilation);
|
|
25316
|
+
} finally {
|
|
25317
|
+
budget.setRetainedValues(retainedPattern, void 0);
|
|
25318
|
+
compilation.dispose();
|
|
25319
|
+
operation.release();
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25282
25322
|
function callMatchLikeMethod(value, methodName, args, compilation) {
|
|
25283
25323
|
const regex = args[0];
|
|
25284
25324
|
if (!isSandboxRegex(regex))
|
|
@@ -25296,15 +25336,16 @@ function callMatchLikeMethod(value, methodName, args, compilation) {
|
|
|
25296
25336
|
return toMatchArray(executeRegex(regex, value), value);
|
|
25297
25337
|
if (methodName === "match") regex.lastIndex = 0;
|
|
25298
25338
|
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
|
|
25299
|
-
const matches = collectRegexMatches(matcher, value, true);
|
|
25339
|
+
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget);
|
|
25300
25340
|
if (methodName === "match" && matches.length === 0) return null;
|
|
25301
25341
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
25302
25342
|
}
|
|
25303
|
-
function collectRegexMatches(regex, value, all) {
|
|
25343
|
+
function collectRegexMatches(regex, value, all, budget) {
|
|
25304
25344
|
const matches = [];
|
|
25305
25345
|
do {
|
|
25306
25346
|
const match = executeRegex(regex, value);
|
|
25307
25347
|
if (match === null) break;
|
|
25348
|
+
budget?.allocateArrayLength(matches.length + 1);
|
|
25308
25349
|
matches.push(match);
|
|
25309
25350
|
if (all && match.text.length === 0) regex.lastIndex += 1;
|
|
25310
25351
|
} while (all);
|
|
@@ -28161,7 +28202,8 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
28161
28202
|
args.value,
|
|
28162
28203
|
context.budget,
|
|
28163
28204
|
(closure, closureArgs) => invokeSandboxClosure(closure, closureArgs, context, context.callStack),
|
|
28164
|
-
context.compilation
|
|
28205
|
+
context.compilation,
|
|
28206
|
+
createCoercionContext(context)
|
|
28165
28207
|
)
|
|
28166
28208
|
};
|
|
28167
28209
|
} catch (error) {
|
|
@@ -30591,32 +30633,43 @@ function defineDataProperty(target, key, value) {
|
|
|
30591
30633
|
}
|
|
30592
30634
|
|
|
30593
30635
|
// packages/safe-js/src/interp/globals/regex.ts
|
|
30594
|
-
function createRegexGlobals(
|
|
30595
|
-
const
|
|
30596
|
-
const selected =
|
|
30636
|
+
function createRegexGlobals(options) {
|
|
30637
|
+
const invoke = (construct) => async (args, context) => {
|
|
30638
|
+
const selected = options.compileOwner ?? context?.compilation?.owner;
|
|
30597
30639
|
if (context?.compilation?.owner !== void 0 && selected !== context.compilation.owner) {
|
|
30598
30640
|
throw new SandboxError("reentry");
|
|
30599
30641
|
}
|
|
30600
|
-
const operation =
|
|
30601
|
-
const compilation = context?.compilation
|
|
30642
|
+
const operation = options.budget.acquireCompileOwner(false, selected);
|
|
30643
|
+
const compilation = context?.compilation?.owner === operation.owner ? context.compilation : new CompileScope(operation.owner);
|
|
30644
|
+
let source = "";
|
|
30645
|
+
const retained = {};
|
|
30646
|
+
options.budget.setRetainedValues(retained, () => [...args, source]);
|
|
30602
30647
|
try {
|
|
30648
|
+
const pattern = args[0];
|
|
30649
|
+
const flags = args[1];
|
|
30650
|
+
if (!construct && isSandboxRegex(pattern) && flags === void 0) return pattern;
|
|
30651
|
+
const sourceValue = isSandboxRegex(pattern) ? pattern.source : pattern;
|
|
30652
|
+
const flagsValue = isSandboxRegex(pattern) && flags === void 0 ? pattern.flags : flags;
|
|
30653
|
+
source = sourceValue === void 0 ? "" : await sandboxString(sourceValue, options.budget, context);
|
|
30654
|
+
const flagText = flagsValue === void 0 ? "" : await sandboxString(flagsValue, options.budget, context);
|
|
30603
30655
|
const regex = createSandboxRegex(
|
|
30604
|
-
|
|
30605
|
-
|
|
30656
|
+
source,
|
|
30657
|
+
flagText,
|
|
30606
30658
|
0,
|
|
30607
30659
|
compilation
|
|
30608
30660
|
);
|
|
30609
|
-
if (
|
|
30610
|
-
reconcileCompiledValues(
|
|
30661
|
+
if (compilation !== context?.compilation) {
|
|
30662
|
+
reconcileCompiledValues(options.budget, [regex], compilation);
|
|
30611
30663
|
}
|
|
30612
30664
|
return regex;
|
|
30613
30665
|
} finally {
|
|
30614
|
-
|
|
30615
|
-
|
|
30666
|
+
options.budget.setRetainedValues(retained, void 0);
|
|
30667
|
+
if (compilation !== context?.compilation) compilation.dispose();
|
|
30668
|
+
operation.release();
|
|
30616
30669
|
}
|
|
30617
30670
|
};
|
|
30618
30671
|
return {
|
|
30619
|
-
RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call:
|
|
30672
|
+
RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: invoke(false), construct: invoke(true) })
|
|
30620
30673
|
};
|
|
30621
30674
|
}
|
|
30622
30675
|
|
|
@@ -31173,7 +31226,7 @@ function createBuiltinBindings(options) {
|
|
|
31173
31226
|
...createObjectArrayGlobals(options),
|
|
31174
31227
|
...createMiscGlobals(options),
|
|
31175
31228
|
...createPromiseGlobals(options),
|
|
31176
|
-
...createRegexGlobals(options
|
|
31229
|
+
...createRegexGlobals(options)
|
|
31177
31230
|
};
|
|
31178
31231
|
}
|
|
31179
31232
|
|
|
@@ -33296,4 +33349,4 @@ export {
|
|
|
33296
33349
|
FileSnapshotBackend,
|
|
33297
33350
|
run
|
|
33298
33351
|
};
|
|
33299
|
-
//# sourceMappingURL=chunk-
|
|
33352
|
+
//# sourceMappingURL=chunk-XI33TU4X.js.map
|