@poe-platform/safe-js 0.1.119 → 0.1.120

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-6LFWVA64.js";
30
+ } from "./chunk-XI33TU4X.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8245,4 +8245,4 @@ export {
8245
8245
  parseMcpConfig,
8246
8246
  makeMcpModule
8247
8247
  };
8248
- //# sourceMappingURL=chunk-IXR26PKW.js.map
8248
+ //# sourceMappingURL=chunk-XEFVZTJ7.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(target, property, args)
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
- const match = executeRegex(target, String(args[0]));
8559
- return methodName === "test" ? match !== null : toMatchArray(match, String(args[0]));
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);
@@ -33328,4 +33349,4 @@ export {
33328
33349
  FileSnapshotBackend,
33329
33350
  run
33330
33351
  };
33331
- //# sourceMappingURL=chunk-6LFWVA64.js.map
33352
+ //# sourceMappingURL=chunk-XI33TU4X.js.map