From 7984c7562cd96bcbd9ccfdcb2a9dc8e38cbad885 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 27 Sep 2016 08:31:12 -0400 Subject: [PATCH] fix #2033 --- src/css/popup.css | 5 ---- src/js/dynamic-net-filtering.js | 42 +++++++-------------------------- src/js/popup.js | 2 +- src/js/ublock.js | 8 +++++-- 4 files changed, 16 insertions(+), 41 deletions(-) diff --git a/src/css/popup.css b/src/css/popup.css index 3e0001b20..ca61207dd 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -473,11 +473,6 @@ body.portrait #firewallContainer > div > span:nth-of-type(4) { #actionSelector.colorBlind > span:nth-of-type(3) { background-color: rgb(0, 19, 110); } -#firewallContainer span.aRule #actionSelector > span:nth-of-type(1), -#firewallContainer span.nRule #actionSelector > span:nth-of-type(2), -#firewallContainer span.bRule #actionSelector > span:nth-of-type(3) { - visibility: hidden; - } #rulesetTools { background-color: transparent; diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js index fff159efc..fc89f24cc 100644 --- a/src/js/dynamic-net-filtering.js +++ b/src/js/dynamic-net-filtering.js @@ -1,7 +1,7 @@ /******************************************************************************* - uBlock - a browser extension to block requests. - Copyright (C) 2014 Raymond Hill + uBlock Origin - a browser extension to block requests. + Copyright (C) 2014-2016 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 @@ -19,15 +19,15 @@ Home: https://github.com/gorhill/uBlock */ -/* global punycode, µBlock */ +/* global punycode */ /* jshint bitwise: false */ +'use strict'; + /******************************************************************************/ µBlock.Firewall = (function() { -'use strict'; - /******************************************************************************/ var magicId = 'chmdgxwtetgu'; @@ -94,6 +94,10 @@ var isIPAddress = function(hostname) { /******************************************************************************/ +// TODO: Rearrange the code so as to avoid calling isIPAddress() from within +// toBroaderHostname(). A hostname will never magically become an IP address +// when broadened -- so no need to test for this condition each call. + var toBroaderHostname = function(hostname) { if ( isIPAddress(hostname) ) { return '*'; @@ -261,38 +265,10 @@ Matrix.prototype.unsetCell = function(srcHostname, desHostname, type) { return true; }; -/******************************************************************************/ - -Matrix.prototype.setCellZ = function(srcHostname, desHostname, type, action) { - this.evaluateCellZY(srcHostname, desHostname, type); - if ( this.r === action ) { - return false; - } - this.setCell(srcHostname, desHostname, type, 0); - this.evaluateCellZY(srcHostname, desHostname, type); - if ( this.r === action ) { - return true; - } - this.setCell(srcHostname, desHostname, type, action); - return true; -}; - -/******************************************************************************/ - -Matrix.prototype.blockCell = function(srcHostname, desHostname, type) { - return this.setCellZ(srcHostname, desHostname, type, 1); -}; - // https://www.youtube.com/watch?v=Csewb_eIStY /******************************************************************************/ -Matrix.prototype.allowCell = function(srcHostname, desHostname, type) { - return this.setCellZ(srcHostname, desHostname, type, 2); -}; - -/******************************************************************************/ - Matrix.prototype.evaluateCell = function(srcHostname, desHostname, type) { var key = srcHostname + ' ' + desHostname; var bitmap = this.rules[key]; diff --git a/src/js/popup.js b/src/js/popup.js index 7f16de3d3..bd1839800 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -239,7 +239,7 @@ var updateFirewallCell = function(scope, des, type, rule) { cell.toggleClass(action + 'Rule', true); } - // Use dark shade visual cue if the filter is specific to the cell. + // Use dark shade visual cue if the rule is specific to the cell. var ownRule = false; var matches = reSrcHostnameFromRule.exec(rule); if ( matches !== null ) { diff --git a/src/js/ublock.js b/src/js/ublock.js index 63775a564..7472577ea 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -330,11 +330,15 @@ var matchWhitelistDirective = function(url, hostname, directive) { /******************************************************************************/ +// https://github.com/gorhill/uBlock/issues/2033 +// Always set own rules, trying to be fancy to avoid setting seemingly +// (but not really) redundant rules led to this issue. + µBlock.toggleFirewallRule = function(details) { var requestType = details.requestType; if ( details.action !== 0 ) { - this.sessionFirewall.setCellZ(details.srcHostname, details.desHostname, requestType, details.action); + this.sessionFirewall.setCell(details.srcHostname, details.desHostname, requestType, details.action); } else { this.sessionFirewall.unsetCell(details.srcHostname, details.desHostname, requestType); } @@ -342,7 +346,7 @@ var matchWhitelistDirective = function(url, hostname, directive) { // https://github.com/chrisaljoudi/uBlock/issues/731#issuecomment-73937469 if ( details.persist ) { if ( details.action !== 0 ) { - this.permanentFirewall.setCellZ(details.srcHostname, details.desHostname, requestType, details.action); + this.permanentFirewall.setCell(details.srcHostname, details.desHostname, requestType, details.action); } else { this.permanentFirewall.unsetCell(details.srcHostname, details.desHostname, requestType, details.action); }