1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-01-10 17:23:18 +01:00

Improved: Only remove metadata if origin is not on allowed list (#179)

This commit is contained in:
nobody 2020-11-21 07:01:46 +01:00
parent fdd3945024
commit de4b23a129
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A

View File

@ -46,11 +46,19 @@ requestSanitizer.disable = function () {
*/
requestSanitizer._stripMetadata = function (requestDetails) {
let sensitiveHeaders, initiatorDomain, allowlistedDomains;
let sensitiveHeaders = [Header.COOKIE, Header.ORIGIN, Header.REFERER];
sensitiveHeaders = [Header.COOKIE, Header.ORIGIN, Header.REFERER];
initiatorDomain = helpers.extractDomainFromUrl(requestDetails.originUrl, true);
allowlistedDomains = stateManager._domainIsListed(initiatorDomain);
if (allowlistedDomains) {
return {
[WebRequest.HEADERS]: requestDetails.requestHeaders,
};
}
for (let i = 0; i < requestDetails.requestHeaders.length; ++i) {
if (sensitiveHeaders.indexOf(requestDetails.requestHeaders[i].name) > -1) {
requestDetails.requestHeaders.splice(i--, 1);
}