From 77133b58c667b0b1eb53f23083118fe55f466835 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 4 Feb 2015 09:03:34 -0500 Subject: [PATCH] this fixes #682 --- src/_locales/en/messages.json | 4 ++++ src/js/dynamic-net-filtering.js | 13 +++---------- src/js/messaging.js | 2 ++ src/js/popup.js | 16 +++++++--------- src/popup.html | 3 ++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index cd8383267..84666bcdc 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -151,6 +151,10 @@ "message":"3rd-party frames are blocked<\/b> everywhere by default", "description":"" }, + "popupAnyRulePrompt":{ + "message":"all", + "description":"" + }, "popupImageRulePrompt":{ "message":"images", "description":"" diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js index 071d414ad..e776f8c93 100644 --- a/src/js/dynamic-net-filtering.js +++ b/src/js/dynamic-net-filtering.js @@ -39,7 +39,6 @@ var Matrix = function() { /******************************************************************************/ var supportedDynamicTypes = { - '*': true, 'inline-script': true, '1p-script': true, '3p-script': true, @@ -243,21 +242,15 @@ Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) { Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) { this.r = 0; - this.type = '*'; // Specific-destination + any type - this.y = desHostname; - this.r = this.evaluateCellZ(srcHostname, desHostname, '*'); - if ( this.r !== 0 ) { return this; } + this.type = '*'; var d = desHostname; - for (;;) { - d = toBroaderHostname(d); - if ( d === '*' ) { - break; - } + while ( d !== '*' ) { this.y = d; this.r = this.evaluateCellZ(srcHostname, d, '*'); if ( this.r !== 0 ) { return this; } + d = toBroaderHostname(d); } // Any destination + specific-type diff --git a/src/js/messaging.js b/src/js/messaging.js index 8bebbc165..acb20f92e 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -145,6 +145,7 @@ var getHostnameDict = function(hostnameToCountMap) { var getDynamicFilterRules = function(srcHostname, desHostnames) { var r = {}; var dFiltering = µb.dynamicNetFilteringEngine; + r['/ * *'] = dFiltering.evaluateCellZY('*', '*', '*').toFilterString(); r['/ * image'] = dFiltering.evaluateCellZY('*', '*', 'image').toFilterString(); r['/ * inline-script'] = dFiltering.evaluateCellZY('*', '*', 'inline-script').toFilterString(); r['/ * 1p-script'] = dFiltering.evaluateCellZY('*', '*', '1p-script').toFilterString(); @@ -154,6 +155,7 @@ var getDynamicFilterRules = function(srcHostname, desHostnames) { return r; } + r['. * *'] = dFiltering.evaluateCellZY(srcHostname, '*', '*').toFilterString(); r['. * image'] = dFiltering.evaluateCellZY(srcHostname, '*', 'image').toFilterString(); r['. * inline-script'] = dFiltering.evaluateCellZY(srcHostname, '*', 'inline-script').toFilterString(); r['. * 1p-script'] = dFiltering.evaluateCellZY(srcHostname, '*', '1p-script').toFilterString(); diff --git a/src/js/popup.js b/src/js/popup.js index 58003ff16..6144b95aa 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -33,7 +33,7 @@ var popupData; var dfPaneBuilt = false; var popupHeight; var reIP = /^\d+(?:\.\d+){1,3}$/; -var reSrcHostnameFromRule = /^d[abn]:([^ ]+) ([^ ]+)/; +var reSrcHostnameFromRule = /^d[abn]:([^ ]+) ([^ ]+) ([^ ]+)/; var scopeToSrcHostnameMap = { '/': '*', '.': '' @@ -200,12 +200,13 @@ var updateDynamicFilterCell = function(scope, des, type, rule) { var ownRule = false; var matches = reSrcHostnameFromRule.exec(rule); if ( matches !== null ) { - ownRule = matches[2] === des && - matches[1] === scopeToSrcHostnameMap[scope]; + ownRule = matches[2] === des && + matches[3] === type && + matches[1] === scopeToSrcHostnameMap[scope]; } cell.toggleClass('ownRule', ownRule); - if ( scope !== '.' || type !== '*' ) { + if ( scope !== '.' || des === '*' ) { return; } if ( popupData.hostnameDict.hasOwnProperty(des) === false ) { @@ -269,12 +270,9 @@ var buildAllDynamicFilters = function() { var key, des; for ( var i = 0; i < keys.length; i++ ) { key = keys[i]; - // Specific-type rules -- these are built-in - if ( key.slice(-1) !== '*' ) { - continue; - } des = key.slice(2, key.indexOf(' ', 2)); - if ( desHostnameDone.hasOwnProperty(des) ) { + // Specific-type rules -- these are built-in + if ( des === '*' || desHostnameDone.hasOwnProperty(des) ) { continue; } addDynamicFilterRow(des); diff --git a/src/popup.html b/src/popup.html index 61ccfbbb7..4aa436101 100644 --- a/src/popup.html +++ b/src/popup.html @@ -26,12 +26,13 @@
+
-
+