From 266a7507b8c05a81fe596a14c2e398b59028ed7a Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 21 Feb 2021 07:41:09 -0500 Subject: [PATCH] Fix regression when initializing popup panel Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1505 Regression from: - https://github.com/gorhill/uBlock/commit/435c91636fdbfe90742b3f7c68df07283b63a37d --- src/js/messaging.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/js/messaging.js b/src/js/messaging.js index 791df5859..ca3d8383c 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -263,31 +263,29 @@ const firewallRuleTypes = [ ]; const getFirewallRules = function(src, out) { - const { hostnameDict } = out; - const ruleset = {}; + const ruleset = out.firewallRules = {}; const df = µb.sessionFirewall; for ( const type of firewallRuleTypes ) { - let r = df.lookupRuleData('*', '*', type); + const r = df.lookupRuleData('*', '*', type); if ( r === undefined ) { continue; } ruleset[`/ * ${type}`] = r; } - if ( typeof src !== 'string' ) { return out; } + if ( typeof src !== 'string' ) { return; } for ( const type of firewallRuleTypes ) { - let r = df.lookupRuleData(src, '*', type); + const r = df.lookupRuleData(src, '*', type); if ( r === undefined ) { continue; } ruleset[`. * ${type}`] = r; } + const { hostnameDict } = out; for ( const des in hostnameDict ) { let r = df.lookupRuleData('*', des, '*'); if ( r !== undefined ) { ruleset[`/ ${des} *`] = r; } r = df.lookupRuleData(src, des, '*'); if ( r !== undefined ) { ruleset[`. ${des} *`] = r; } } - - out.firewallRules = ruleset; }; const popupDataFromTabId = function(tabId, tabTitle) { @@ -358,7 +356,7 @@ const popupDataFromTabId = function(tabId, tabTitle) { ); } else { r.hostnameDict = {}; - r.firewallRules = getFirewallRules(); + getFirewallRules(undefined, r); } r.matrixIsDirty = µb.sessionFirewall.hasSameRules(