Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Don't block ad hosts if they are 1st party
Browse files Browse the repository at this point in the history
Fix #1353

Auditors: @bbondy
  • Loading branch information
diracdeltas committed Apr 15, 2016
1 parent dd3c38e commit 52811f8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/adBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ let mapFilterType = {
const startAdBlocking = (adblock, resourceName, shouldCheckMainFrame) => {
Filtering.registerBeforeRequestFilteringCB((details) => {
const firstPartyUrl = URL.parse(details.firstPartyUrl)
let firstPartyUrlHost = firstPartyUrl.hostname || ''
if (firstPartyUrlHost.startsWith('www.')) {
firstPartyUrlHost = firstPartyUrlHost.substring(4)
}
const urlHost = URL.parse(details.url).hostname
const cancel = firstPartyUrl.protocol &&
(shouldCheckMainFrame || details.resourceType !== 'mainFrame') &&
firstPartyUrl.protocol.startsWith('http') &&
mapFilterType[details.resourceType] !== undefined &&
urlHost !== firstPartyUrlHost &&

This comment has been minimized.

Copy link
@bbondy

bbondy Apr 17, 2016

Member

This is actually affecting safe browsing as well which I don't think you want here. You want to check shouldCheckMainFrame as well.

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Apr 18, 2016

Author Member

Great catch, will fix

adblock.matches(details.url, mapFilterType[details.resourceType], firstPartyUrl.host)
return {
cancel,
Expand Down

0 comments on commit 52811f8

Please sign in to comment.