mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
add failsafe
This commit is contained in:
parent
b8334993ae
commit
3826197093
2 changed files with 12 additions and 0 deletions
|
@ -53,12 +53,19 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
|
|
||||||
client.Proxy("EventTarget.prototype.addEventListener", {
|
client.Proxy("EventTarget.prototype.addEventListener", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
|
unproxy(ctx, client);
|
||||||
// if (ctx.args[0] === "message" && iswindow) debugger;
|
// if (ctx.args[0] === "message" && iswindow) debugger;
|
||||||
if (typeof ctx.args[1] === "function")
|
if (typeof ctx.args[1] === "function")
|
||||||
ctx.args[1] = wraplistener(ctx.args[1]);
|
ctx.args[1] = wraplistener(ctx.args[1]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.Proxy("EventTarget.prototype.dispatchEvent", {
|
||||||
|
apply(ctx) {
|
||||||
|
unproxy(ctx, client);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: removeEventListener
|
// TODO: removeEventListener
|
||||||
|
|
||||||
if (!iswindow) return;
|
if (!iswindow) return;
|
||||||
|
|
|
@ -45,6 +45,11 @@ export async function swfetch(
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const url = new URL(decodeUrl(request.url));
|
const url = new URL(decodeUrl(request.url));
|
||||||
|
if (url.origin == new URL(request.url).origin) {
|
||||||
|
throw new Error(
|
||||||
|
"attempted to fetch from same origin - this means the site has obtained a reference to the real origin, aborting"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
for (const [key, value] of request.headers.entries()) {
|
for (const [key, value] of request.headers.entries()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue