Skip to content

Commit

Permalink
Optimize widget surrogate message frame check
Browse files Browse the repository at this point in the history
For messages from frames with same host as tab host.
  • Loading branch information
ghostwords committed Jul 17, 2024
1 parent 00b351a commit 9936230
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,8 @@ function dispatcher(request, sender, sendResponse) {
// proxies surrogate script-initiated widget replacement messages
// from one content script to another
case "widgetFromSurrogate": {
let tab_host = extractHostFromURL(sender.tab.url);
let tab_url = sender.tab.url,
tab_host = extractHostFromURL(tab_url);
if (!badger.isPrivacyBadgerEnabled(tab_host)) {
break;
}
Expand All @@ -1775,13 +1776,16 @@ function dispatcher(request, sender, sendResponse) {
// implications of accepting pbSurrogateMessage events
// from third-party scripts in nested frames
if (!request.frameUrl.startsWith('https://cdn.embedly.com/')) {
let frame_host = extractHostFromURL(request.frameUrl);
// CNAME uncloaking
if (utils.hasOwn(badger.cnameDomains, frame_host)) {
frame_host = badger.cnameDomains[frame_host];
}
if (!frame_host || utils.isThirdPartyDomain(frame_host, tab_host)) {
break;
let tab_proto = tab_url.slice(0, tab_url.indexOf(tab_host));
if (!request.frameUrl.startsWith(tab_proto + tab_host)) {
let frame_host = extractHostFromURL(request.frameUrl);
// CNAME uncloaking
if (utils.hasOwn(badger.cnameDomains, frame_host)) {
frame_host = badger.cnameDomains[frame_host];
}
if (!frame_host || utils.isThirdPartyDomain(frame_host, tab_host)) {
break;
}
}
}

Expand Down

0 comments on commit 9936230

Please sign in to comment.