From 6de836b21fe35c3c7bcf5a3a024ab6f0bfa2b9b8 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 7 Apr 2015 21:46:39 -0600 Subject: [PATCH] Fixes #1205 and #1208 --- src/js/pagestore.js | 38 ++++++++++++++++++++++++++++++++------ src/js/traffic.js | 3 ++- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/js/pagestore.js b/src/js/pagestore.js index d5d1e4418..b4b75acf6 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -417,12 +417,15 @@ FrameStore.factory = function(rootHostname, frameURL) { FrameStore.prototype.init = function(rootHostname, frameURL) { var µburi = µb.URI; + this.pageURL = frameURL; this.pageHostname = µburi.hostnameFromURI(frameURL); this.pageDomain = µburi.domainFromHostname(this.pageHostname) || this.pageHostname; this.rootHostname = rootHostname; this.rootDomain = µburi.domainFromHostname(rootHostname) || rootHostname; // This is part of the filtering evaluation context this.requestURL = this.requestHostname = this.requestType = ''; + this.netFiltering = true; + this.netFilteringReadTime = 0; return this; }; @@ -440,6 +443,15 @@ FrameStore.prototype.dispose = function() { }; /******************************************************************************/ + +FrameStore.prototype.getNetFilteringSwitch = function() { + if ( this.netFilteringReadTime < µb.netWhitelistModifyTime ) { + this.netFiltering = µb.getNetFilteringSwitch(this.pageURL); + this.netFilteringReadTime = Date.now(); + } + return this.netFiltering; +}; + /******************************************************************************/ // To mitigate memory churning @@ -637,8 +649,15 @@ PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) { /******************************************************************************/ PageStore.prototype.filterRequest = function(context) { - - if ( this.getNetFilteringSwitch() === false ) { + if(context.preNavigationHeader) { // sometimes we get inline-script queries before being + // informed of navigation + if(µb.getNetFilteringSwitch(context.requestURL) === false) { + return ''; + } + } + if(this.getNetFilteringSwitch() === false || // if we're turned off (whitelisted) + (typeof context.getNetFilteringSwitch === "function" && // or we're in a frame that's whitelisted + context.getNetFilteringSwitch() === false)) { if ( collapsibleRequestTypes.indexOf(context.requestType) !== -1 ) { this.netFilteringCache.add(context, ''); } @@ -659,7 +678,7 @@ PageStore.prototype.filterRequest = function(context) { // We evaluate dynamic filtering first, and hopefully we can skip // evaluation of static filtering. if ( µb.userSettings.advancedUserEnabled ) { - var df = µb.sessionFirewall.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType); + var df = µb.sessionFirewall.evaluateCellZY(context.pageHostname, context.requestHostname, context.requestType); if ( df.mustBlockOrAllow() ) { result = df.toFilterString(); } @@ -687,8 +706,15 @@ var collapsibleRequestTypes = 'image sub_frame object'; /******************************************************************************/ PageStore.prototype.filterRequestNoCache = function(context) { - - if ( this.getNetFilteringSwitch() === false ) { + if(context.preNavigationHeader) { // sometimes we get inline-script queries before being + // informed of navigation + if(µb.getNetFilteringSwitch(context.requestURL) === false) { + return ''; + } + } + if(this.getNetFilteringSwitch() === false || // if we're turned off (whitelisted) + (typeof context.getNetFilteringSwitch === "function" && // or we're in a frame that's whitelisted + context.getNetFilteringSwitch() === false)) { return ''; } @@ -700,7 +726,7 @@ PageStore.prototype.filterRequestNoCache = function(context) { // We evaluate dynamic filtering first, and hopefully we can skip // evaluation of static filtering. if ( µb.userSettings.advancedUserEnabled ) { - var df = µb.sessionFirewall.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType); + var df = µb.sessionFirewall.evaluateCellZY(context.pageHostname, context.requestHostname, context.requestType); if ( df.mustBlockOrAllow() ) { result = df.toFilterString(); } diff --git a/src/js/traffic.js b/src/js/traffic.js index 6fe0bcb95..564ae7d98 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -392,7 +392,8 @@ var onHeadersReceived = function(details) { rootHostname: requestHostname, rootDomain: contextDomain, pageHostname: requestHostname, - pageDomain: contextDomain + pageDomain: contextDomain, + preNavigationHeader: true }; } else { context = pageStore;