Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/fetch): no auth on cross origin redirect #16745

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
18 changes: 18 additions & 0 deletions ext/fetch/26_fetch.js
Expand Up @@ -308,6 +308,16 @@
return response;
}

/**
* @param {URL} a
* @param {URL} b
* @returns {boolean}
*/
function isSameOrigin(a, b) {
if (a.origin === null) return false;
return a.origin === b.origin;
}

/**
* @param {InnerRequest} request
* @param {InnerResponse} response
Expand Down Expand Up @@ -366,6 +376,14 @@
}
}
}
if (!isSameOrigin(request.currentUrl(), locationURL)) {
for (let i = 0; i < request.headerList.length; i++) {
if (byteLowerCase(request.headerList[i][0]) == "authorization") {
ArrayPrototypeSplice(request.headerList, i, 1);
i--;
}
}
}
if (request.body !== null) {
const res = extractBody(request.body.source);
request.body = res.body;
Expand Down