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

Ignore session cookies #2420

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/js/heuristicblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ function hasCookieTracking(details, origin) {
let cookie = utils.parseCookie(cookies[i], {
noDecode: true,
skipAttributes: true,
skipNonValues: true
skipNonValues: true,
ignoreSessionCookies: true,
});

// loop over every name/value pair in every cookie
Expand Down
14 changes: 11 additions & 3 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ function parseCookie(str, opts) {
];

let parsed = {},
cookies = str.replace(/\n/g, ";").split(";");
cookies = str.replace(/\n/g, ";").split(";"),
is_session_cookie = true;

for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i],
Expand All @@ -355,8 +356,11 @@ function parseCookie(str, opts) {
value = "";
}

if (opts.skipAttributes &&
COOKIE_ATTRIBUTES.indexOf(name.toLowerCase()) != -1) {
let lname = name.toLowerCase();
if (opts.ignoreSessionCookies && (lname == "expires" || lname == "max-age")) {
is_session_cookie = false;
}
if (opts.skipAttributes && COOKIE_ATTRIBUTES.includes(lname)) {
continue;
}

Expand Down Expand Up @@ -387,6 +391,10 @@ function parseCookie(str, opts) {
}
}

if (opts.ignoreSessionCookies && is_session_cookie) {
return {};
}

return parsed;
}

Expand Down