From 51a4e9ccf4c0262baf13353ef325a73922992876 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 22 Jul 2018 10:47:02 -0400 Subject: [PATCH] fix #2763 --- src/js/logger-ui.js | 2 +- src/js/messaging.js | 6 +----- src/js/pagestore.js | 8 +++----- src/js/reverselookup-worker.js | 6 ++++++ src/js/reverselookup.js | 24 ++++++++++++------------ src/js/static-net-filtering.js | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 4e31996c2..3dbb17abc 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -1363,7 +1363,7 @@ var reverseLookupManager = (function() { 'loggerUI', { what: 'listsFromCosmeticFilter', - hostname: row.getAttribute('data-hn-frame') || '', + url: row.cells[5].textContent, rawFilter: rawFilter, }, reverseLookupDone diff --git a/src/js/messaging.js b/src/js/messaging.js index bece1ee63..2e661129a 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -69,11 +69,7 @@ var onMessage = function(request, sender, callback) { return; case 'listsFromCosmeticFilter': - µb.staticFilteringReverseLookup.fromCosmeticFilter( - request.hostname, - request.rawFilter, - callback - ); + µb.staticFilteringReverseLookup.fromCosmeticFilter(request, callback); return; case 'reloadAllFilters': diff --git a/src/js/pagestore.js b/src/js/pagestore.js index ee4440266..fd0188c02 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2018 Raymond Hill + Copyright (C) 2014-present Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -319,10 +319,8 @@ PageStore.prototype.init = function(tabId, context) { // Support `generichide` filter option. this.noGenericCosmeticFiltering = this.noCosmeticFiltering; if ( this.noGenericCosmeticFiltering !== true ) { - var result = µb.staticNetFilteringEngine.matchStringExactType( - this.createContextFromPage(), - tabContext.normalURL, - 'generichide' + let result = µb.staticNetFilteringEngine.matchStringGenericHide( + tabContext.normalURL ); this.noGenericCosmeticFiltering = result === 2; if ( diff --git a/src/js/reverselookup-worker.js b/src/js/reverselookup-worker.js index 8377097eb..f520c8377 100644 --- a/src/js/reverselookup-worker.js +++ b/src/js/reverselookup-worker.js @@ -172,6 +172,12 @@ var fromCosmeticFilter = function(details) { if ( end === -1 ) { end = content.length; } pos = end; fargs = JSON.parse(content.slice(beg, end)); + + // https://github.com/gorhill/uBlock/issues/2763 + if ( fargs[0] >= 0 && fargs[0] <= 5 && details.ignoreGeneric ) { + continue; + } + switch ( fargs[0] ) { case 0: // id-based if ( diff --git a/src/js/reverselookup.js b/src/js/reverselookup.js index d407f853e..922c7e84a 100644 --- a/src/js/reverselookup.js +++ b/src/js/reverselookup.js @@ -161,12 +161,10 @@ var fromNetFilter = function(compiledFilter, rawFilter, callback) { /******************************************************************************/ -var fromCosmeticFilter = function(hostname, rawFilter, callback) { - if ( typeof callback !== 'function' ) { - return; - } +var fromCosmeticFilter = function(details, callback) { + if ( typeof callback !== 'function' ) { return; } - if ( rawFilter === '' ) { + if ( details.rawFilter === '' ) { callback(); return; } @@ -176,17 +174,19 @@ var fromCosmeticFilter = function(hostname, rawFilter, callback) { workerTTLTimer = null; } - var onWorkerReady = function() { - var id = messageId++; - var message = { + let onWorkerReady = function() { + let id = messageId++; + let hostname = µBlock.URI.hostnameFromURI(details.url); + pendingResponses[id] = callback; + worker.postMessage({ what: 'fromCosmeticFilter', id: id, domain: µBlock.URI.domainFromHostname(hostname), hostname: hostname, - rawFilter: rawFilter - }; - pendingResponses[id] = callback; - worker.postMessage(message); + ignoreGeneric: µBlock.staticNetFilteringEngine + .matchStringGenericHide(details.url) === 2, + rawFilter: details.rawFilter + }); // The worker will be shutdown after n minutes without being used. workerTTLTimer = vAPI.setTimeout(stopWorker, workerTTL); diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 76bc35f8b..5849efa04 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2018 Raymond Hill + Copyright (C) 2014-present Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2525,14 +2525,14 @@ FilterContainer.prototype.matchTokens = function(bucket, url) { // https://github.com/gorhill/uBlock/issues/2103 // User may want to override `generichide` exception filters. -FilterContainer.prototype.matchStringGenericHide = function(context, requestURL) { - var url = this.urlTokenizer.setURL(requestURL); +FilterContainer.prototype.matchStringGenericHide = function(requestURL) { + let url = this.urlTokenizer.setURL(requestURL); // https://github.com/gorhill/uBlock/issues/2225 // Important: this is used by FilterHostnameDict.match(). requestHostnameRegister = µb.URI.hostnameFromURI(url); - var bucket = this.categories.get(genericHideException); + let bucket = this.categories.get(genericHideException); if ( !bucket || this.matchTokens(bucket, url) === false ) { this.fRegister = null; return 0; @@ -2557,7 +2557,7 @@ FilterContainer.prototype.matchStringGenericHide = function(context, requestURL) FilterContainer.prototype.matchStringExactType = function(context, requestURL, requestType) { // Special cases. if ( requestType === 'generichide' ) { - return this.matchStringGenericHide(context, requestURL); + return this.matchStringGenericHide(requestURL); } var type = typeNameToTypeValue[requestType]; if ( type === undefined ) {