From 3a85158dbbaa9c855ae95218099c2ec69bb9e8a5 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 24 Oct 2018 06:55:04 -0300 Subject: [PATCH] fix regression from cabb0d36b679 regarding filter used count per list --- src/js/static-net-filtering.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 71ddb8cc6..2a8d03b77 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1976,7 +1976,10 @@ FilterContainer.prototype.freeze = function() { unserialize = µb.CompiledLineIO.unserialize; for ( let line of this.goodFilters ) { - if ( this.badFilters.has(line) ) { continue; } + if ( this.badFilters.has(line) ) { + this.discardedCount += 1; + continue; + } let args = unserialize(line); let bits = args[0]; @@ -2263,12 +2266,12 @@ FilterContainer.prototype.fromCompiledContent = function(reader) { // 0 = network filters reader.select(0); while ( reader.next() ) { + this.acceptedCount += 1; if ( this.goodFilters.has(reader.line) ) { this.discardedCount += 1; - continue; + } else { + this.goodFilters.add(reader.line); } - this.goodFilters.add(reader.line); - this.acceptedCount += 1; } // 1 = network filters: bad filters @@ -2278,12 +2281,12 @@ FilterContainer.prototype.fromCompiledContent = function(reader) { // incrementally add filters (through "Block element" for example). reader.select(1); while ( reader.next() ) { + this.acceptedCount += 1; if ( this.badFilters.has(reader.line) ) { this.discardedCount += 1; - continue; + } else { + this.badFilters.add(µb.orphanizeString(reader.line)); } - this.badFilters.add(µb.orphanizeString(reader.line)); - this.acceptedCount += 1; } }; @@ -2467,20 +2470,20 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r if ( requestType === 'generichide' ) { return this.matchStringGenericHide(requestURL); } - var type = typeNameToTypeValue[requestType]; - if ( type === undefined ) { - return 0; - } + let type = typeNameToTypeValue[requestType]; + if ( type === undefined ) { return 0; } // Prime tokenizer: we get a normalized URL in return. - var url = this.urlTokenizer.setURL(requestURL); + let url = this.urlTokenizer.setURL(requestURL); // These registers will be used by various filters pageHostnameRegister = context.pageHostname || ''; requestHostnameRegister = µb.URI.hostnameFromURI(url); - var party = isFirstParty(context.pageDomain, requestHostnameRegister) ? FirstParty : ThirdParty, - categories = this.categories, + let party = isFirstParty(context.pageDomain, requestHostnameRegister) + ? FirstParty + : ThirdParty; + let categories = this.categories, catBits, bucket; this.fRegister = null;