Skip to content

Commit

Permalink
fix #3077
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 1, 2017
1 parent e1ba1a3 commit e7e390d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
3 changes: 2 additions & 1 deletion platform/webext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
{
"matches":[
"http://*/*",
"https://*/*"
"https://*/*",
"file://*/*"
],
"js":[
"js/vapi-client.js",
Expand Down
12 changes: 1 addition & 11 deletions src/js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
19 changes: 12 additions & 7 deletions src/js/pagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/******************************************************************************/
Expand Down

0 comments on commit e7e390d

Please sign in to comment.