From 3195f554f73f0bc35403f8f4a2f729857fbbf5e4 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 29 Jan 2019 10:34:58 -0500 Subject: [PATCH] Fix partyness evaluation for cases of base domain-less hostnames Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/402 --- src/js/filtering-context.js | 14 ++++++++++---- src/js/logger-ui.js | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/filtering-context.js b/src/js/filtering-context.js index 39c67a05d..437afdd60 100644 --- a/src/js/filtering-context.js +++ b/src/js/filtering-context.js @@ -191,8 +191,11 @@ // The idea is to minimize the amout of work done to figure out whether // the resource is 3rd-party to the document. is3rdPartyToDoc: function() { - const docDomain = this.getDocDomain(); - if ( this.domain !== undefined ) { return this.domain !== docDomain; } + let docDomain = this.getDocDomain(); + if ( docDomain === '' ) { docDomain = this.docHostname; } + if ( this.domain !== undefined && this.domain !== '' ) { + return this.domain !== docDomain; + } const hostname = this.getHostname(); if ( hostname.endsWith(docDomain) === false ) { return true; } const i = hostname.length - docDomain.length; @@ -248,8 +251,11 @@ // The idea is to minimize the amout of work done to figure out whether // the resource is 3rd-party to the top document. is3rdPartyToTab: function() { - const tabDomain = this.getTabDomain(); - if ( this.domain !== undefined ) { return this.domain !== tabDomain; } + let tabDomain = this.getTabDomain(); + if ( tabDomain === '' ) { tabDomain = this.tabHostname; } + if ( this.domain !== undefined && this.domain !== '' ) { + return this.domain !== tabDomain; + } const hostname = this.getHostname(); if ( hostname.endsWith(tabDomain) === false ) { return true; } const i = hostname.length - tabDomain.length; diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index e9ab744f7..b2884779a 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -193,8 +193,6 @@ const LogEntry = function(details) { this[prop] = details[prop]; } } - // TODO: Shouldn't this be done in µBlock.filteringContext? - // Need to evaluate. if ( this.tabDomain === '' ) { this.tabDomain = this.tabHostname || ''; }