From e7e390d2e2d0664346b9164bf63da1469fa29688 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 1 Oct 2017 07:56:28 -0400 Subject: [PATCH] fix #3077 --- platform/webext/manifest.json | 3 ++- src/js/contentscript.js | 12 +----------- src/js/pagestore.js | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/platform/webext/manifest.json b/platform/webext/manifest.json index 1d2954238..c9fd692d3 100644 --- a/platform/webext/manifest.json +++ b/platform/webext/manifest.json @@ -33,7 +33,8 @@ { "matches":[ "http://*/*", - "https://*/*" + "https://*/*", + "file://*/*" ], "js":[ "js/vapi-client.js", diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 8a22379e9..5838b4dde 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1114,20 +1114,10 @@ vAPI.domCollapser = (function() { var send = function() { processTimer = undefined; toCollapse.set(resquestIdGenerator, toProcess); - // https://github.com/gorhill/uBlock/issues/1927 - // Normalize hostname to avoid trailing dot of FQHN. - var pageHostname = window.location.hostname || ''; - if ( - pageHostname.length && - pageHostname.charCodeAt(pageHostname.length - 1) === 0x2e - ) { - pageHostname = pageHostname.slice(0, -1); - } var msg = { what: 'getCollapsibleBlockedRequests', id: resquestIdGenerator, - pageURL: window.location.href, - pageHostname: pageHostname, + frameURL: window.location.href, resources: toFilter, hash: cachedBlockedSetHash }; diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 429d8bd91..cbac482ea 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -699,21 +699,26 @@ PageStore.prototype.filterLargeMediaElement = function(size) { /******************************************************************************/ PageStore.prototype.getBlockedResources = function(request, response) { - var resources = request.resources; + var µburi = µb.URI, + normalURL = µb.normalizePageURL(this.tabId, request.frameURL), + frameHostname = µburi.hostnameFromURI(normalURL), + resources = request.resources; + // Force some resources to go through the filtering engine in order to + // populate the blocked-resources cache. This is required because for + // some resources it's not possible to detect whether they were blocked + // content script-side (i.e. `iframes` -- unlike `img`). if ( Array.isArray(resources) && resources.length !== 0 ) { - var context = this.createContextFromFrameHostname(request.pageHostname); + var context = this.createContextFromFrameHostname(frameHostname); for ( var resource of resources ) { context.requestType = resource.type; - context.requestHostname = µb.URI.hostnameFromURI(resource.url); + context.requestHostname = µburi.hostnameFromURI(resource.url); context.requestURL = resource.url; this.filterRequest(context); } } - if ( this.netFilteringCache.hash === response.hash ) { - return; - } + if ( this.netFilteringCache.hash === response.hash ) { return; } response.hash = this.netFilteringCache.hash; - response.blockedResources = this.netFilteringCache.lookupAllBlocked(request.pageHostname); + response.blockedResources = this.netFilteringCache.lookupAllBlocked(frameHostname); }; /******************************************************************************/