Skip to content

Commit

Permalink
strip x-client-data headers from requests in webrequest script
Browse files Browse the repository at this point in the history
  • Loading branch information
ablanathtanalba committed Oct 8, 2020
1 parent 60901cd commit 67570bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ function onBeforeSendHeaders(details) {
if (_isTabChromeInternal(tab_id)) {
// DNT policy requests: strip cookies
if (type == "xmlhttprequest" && url.endsWith("/.well-known/dnt-policy.txt")) {
// remove Cookie headers
// remove Cookie headers and X-Client-Data headers
let newHeaders = [];
for (let i = 0, count = details.requestHeaders.length; i < count; i++) {
let header = details.requestHeaders[i];
if (header.name.toLowerCase() != "cookie") {
if (header.name.toLowerCase() != "cookie" && header.name.toLowerCase() != "x-client-data") {
newHeaders.push(header);
}
}
Expand Down Expand Up @@ -187,10 +187,10 @@ function onBeforeSendHeaders(details) {
if (action == constants.COOKIEBLOCK || action == constants.USER_COOKIEBLOCK) {
let newHeaders;

// GET requests: remove cookie headers, reduce referrer header to origin
// GET requests: remove cookie headers and X-client-data headers, reduce referrer header to origin
if (details.method == "GET") {
newHeaders = details.requestHeaders.filter(header => {
return (header.name.toLowerCase() != "cookie");
return (header.name.toLowerCase() != "cookie" && header.name.toLowerCase() != "x-client-data");
}).map(header => {
if (header.name.toLowerCase() == "referer") {
header.value = header.value.slice(
Expand All @@ -201,10 +201,10 @@ function onBeforeSendHeaders(details) {
return header;
});

// remove cookie and referrer headers otherwise
// remove cookie, referrer, and X-Client-Data headers otherwise
} else {
newHeaders = details.requestHeaders.filter(header => {
return (header.name.toLowerCase() != "cookie" && header.name.toLowerCase() != "referer");
return (header.name.toLowerCase() != "cookie" && header.name.toLowerCase() != "referer" && header.name.toLowerCase() != "x-client-data");
});
}

Expand Down

0 comments on commit 67570bd

Please sign in to comment.