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 CHANGED
@@ -128502,7 +128502,7 @@ function getRegexMember(target, property, budget) {
128502
128502
  return createSandboxClosure({
128503
128503
  sandbox: true,
128504
128504
  name: `RegExp#${property}`,
128505
- call: (args) => callRegexMethod(target, property, args)
128505
+ call: (args, context) => callRegexMethod(context?.thisValue, property, args, budget, context)
128506
128506
  });
128507
128507
  }
128508
128508
  function escapeRegexSource(source, budget) {
@@ -128532,9 +128532,30 @@ function setRegexMember(target, property, value) {
128532
128532
  }
128533
128533
  target.lastIndex = Number(value);
128534
128534
  }
128535
- function callRegexMethod(target, methodName, args) {
128536
- const match = executeRegex(target, String(args[0]));
128537
- return methodName === "test" ? match !== null : toMatchArray(match, String(args[0]));
128535
+ async function callRegexMethod(target, methodName, args, budget, context) {
128536
+ if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
128537
+ throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
128538
+ }
128539
+ const retained = {};
128540
+ budget.setRetainedValues(retained, () => [target, ...args]);
128541
+ try {
128542
+ const input = await sandboxString(args[0], budget, context);
128543
+ if (methodName === "test") {
128544
+ const exec2 = context?.getProperty === void 0 ? getSandboxDataProperty(target, "exec", budget) : context.getProperty(target, "exec");
128545
+ if (isSandboxClosure(exec2)) {
128546
+ const result = await invokeBuiltinClosure(exec2, [input], budget, context, target);
128547
+ if (result !== null && typeof result !== "object") {
128548
+ throw new TypeError("RegExp#test exec must return an object or null.");
128549
+ }
128550
+ return result !== null;
128551
+ }
128552
+ }
128553
+ if (!isSandboxRegex(target)) throw new TypeError("RegExp execution requires a regex receiver.");
128554
+ const match = executeRegex(target, input);
128555
+ return methodName === "test" ? match !== null : toMatchArray(match, input);
128556
+ } finally {
128557
+ budget.setRetainedValues(retained, void 0);
128558
+ }
128538
128559
  }
128539
128560
  function executeRegex(target, input) {
128540
128561
  const pattern = getSandboxRegexPattern(target);
@@ -128558,6 +128579,9 @@ var init_regex = __esm({
128558
128579
  "use strict";
128559
128580
  init_values();
128560
128581
  init_engine2();
128582
+ init_builtin_call();
128583
+ init_object_model();
128584
+ init_string_coercion();
128561
128585
  regexMethodNames = /* @__PURE__ */ new Set(["exec", "test"]);
128562
128586
  }
128563
128587
  });