mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
implement direct and indirect eval
This commit is contained in:
parent
e6b237c525
commit
ec8421be8f
12 changed files with 171 additions and 101 deletions
|
@ -1,6 +1,7 @@
|
|||
import { encodeUrl } from "../shared/rewriters/url";
|
||||
import { ScramjetClient } from "./client";
|
||||
import { wrapfn } from ".";
|
||||
import { indirectEval } from "./shared/eval";
|
||||
import { config } from "./shared";
|
||||
|
||||
export function createWindowProxy(
|
||||
client: ScramjetClient,
|
||||
|
@ -9,16 +10,17 @@ export function createWindowProxy(
|
|||
return new Proxy(self, {
|
||||
get(target, prop) {
|
||||
const propIsString = typeof prop === "string";
|
||||
if (propIsString && prop === "location") {
|
||||
return client.locationProxy;
|
||||
} else if (
|
||||
if (prop === "location") return client.locationProxy;
|
||||
|
||||
if (
|
||||
propIsString &&
|
||||
["window", "top", "self", "globalThis", "parent"].includes(prop)
|
||||
) {
|
||||
return self[wrapfn](self[prop]);
|
||||
} else if (propIsString && prop === "$scramjet") {
|
||||
return;
|
||||
}
|
||||
)
|
||||
return self[config.wrapfn](self[prop]);
|
||||
|
||||
if (prop === "$scramjet") return;
|
||||
|
||||
if (prop === "eval") return indirectEval.bind(client);
|
||||
|
||||
const value = Reflect.get(target, prop);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue