poe-code 14.0.55 → 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 +28 -4
- 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-G5LQ37D4.js → chunk-SRYQTOX4.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-6LFWVA64.js → chunk-XI33TU4X.js} +26 -5
- 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/methods/regex.d.ts +3 -3
- package/packages/safe-js/dist/interp/methods/regex.js +32 -5
- package/packages/safe-js/dist/chunks/chunk-6LFWVA64.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-G5LQ37D4.js.map → chunk-SRYQTOX4.js.map} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-SRYQTOX4.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-XI33TU4X.js";
|
|
38
38
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
39
39
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-SRYQTOX4.js";
|
|
30
30
|
import {
|
|
31
31
|
Budget,
|
|
32
32
|
FileSnapshotBackend,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
registerPendingHostCallPolicy,
|
|
51
51
|
restore,
|
|
52
52
|
run
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-XI33TU4X.js";
|
|
54
54
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
55
55
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type SandboxRegex, type SandboxValue } from "../values.js";
|
|
1
|
+
import { type SandboxCallContext, type SandboxRegex, type SandboxValue } from "../values.js";
|
|
2
2
|
import { type RegexMatch } from "../regex/engine.js";
|
|
3
3
|
import type { Budget } from "../budget.js";
|
|
4
4
|
export type RegexMethodName = "exec" | "test";
|
|
5
5
|
export declare function isRegexMethodName(property: string | number): property is RegexMethodName;
|
|
6
|
-
export declare function getRegexMember(target: SandboxRegex, property: string | number, budget
|
|
6
|
+
export declare function getRegexMember(target: SandboxRegex, property: string | number, budget: Budget): SandboxValue | undefined;
|
|
7
7
|
export declare function setRegexMember(target: SandboxRegex, property: string | number, value: SandboxValue): void;
|
|
8
|
-
export declare function callRegexMethod(target:
|
|
8
|
+
export declare function callRegexMethod(target: SandboxValue, methodName: RegexMethodName, args: readonly SandboxValue[], budget: Budget, context?: SandboxCallContext): Promise<SandboxValue>;
|
|
9
9
|
export declare function executeRegex(target: SandboxRegex, input: string): RegexMatch | null;
|
|
10
10
|
export declare function toMatchArray(match: RegexMatch | null, input: string): SandboxValue;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { createSandboxClosure, getSandboxRegexPattern } from "../values.js";
|
|
1
|
+
import { createSandboxClosure, getSandboxRegexPattern, isSandboxClosure, isSandboxRegex } from "../values.js";
|
|
2
2
|
import { matchRegex } from "../regex/engine.js";
|
|
3
|
+
import { invokeBuiltinClosure } from "../builtin-call.js";
|
|
4
|
+
import { getSandboxDataProperty } from "../object-model.js";
|
|
5
|
+
import { sandboxString } from "../string-coercion.js";
|
|
3
6
|
const regexMethodNames = new Set(["exec", "test"]);
|
|
4
7
|
export function isRegexMethodName(property) {
|
|
5
8
|
return typeof property === "string" && regexMethodNames.has(property);
|
|
@@ -19,7 +22,7 @@ export function getRegexMember(target, property, budget) {
|
|
|
19
22
|
return createSandboxClosure({
|
|
20
23
|
sandbox: true,
|
|
21
24
|
name: `RegExp#${property}`,
|
|
22
|
-
call: (args) => callRegexMethod(
|
|
25
|
+
call: (args, context) => callRegexMethod(context?.thisValue, property, args, budget, context)
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
function escapeRegexSource(source, budget) {
|
|
@@ -63,9 +66,33 @@ export function setRegexMember(target, property, value) {
|
|
|
63
66
|
}
|
|
64
67
|
target.lastIndex = Number(value);
|
|
65
68
|
}
|
|
66
|
-
export function callRegexMethod(target, methodName, args) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
export async function callRegexMethod(target, methodName, args, budget, context) {
|
|
70
|
+
if (target === null || typeof target !== "object" || (methodName === "exec" && !isSandboxRegex(target))) {
|
|
71
|
+
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
72
|
+
}
|
|
73
|
+
const retained = {};
|
|
74
|
+
budget.setRetainedValues(retained, () => [target, ...args]);
|
|
75
|
+
try {
|
|
76
|
+
const input = await sandboxString(args[0], budget, context);
|
|
77
|
+
if (methodName === "test") {
|
|
78
|
+
const exec = context?.getProperty === undefined
|
|
79
|
+
? getSandboxDataProperty(target, "exec", budget) : context.getProperty(target, "exec");
|
|
80
|
+
if (isSandboxClosure(exec)) {
|
|
81
|
+
const result = await invokeBuiltinClosure(exec, [input], budget, context, target);
|
|
82
|
+
if (result !== null && typeof result !== "object") {
|
|
83
|
+
throw new TypeError("RegExp#test exec must return an object or null.");
|
|
84
|
+
}
|
|
85
|
+
return result !== null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!isSandboxRegex(target))
|
|
89
|
+
throw new TypeError("RegExp execution requires a regex receiver.");
|
|
90
|
+
const match = executeRegex(target, input);
|
|
91
|
+
return methodName === "test" ? match !== null : toMatchArray(match, input);
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
budget.setRetainedValues(retained, undefined);
|
|
95
|
+
}
|
|
69
96
|
}
|
|
70
97
|
export function executeRegex(target, input) {
|
|
71
98
|
const pattern = getSandboxRegexPattern(target);
|