From be082cb666c98b9cf2019870cfa28691e2656a7f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 29 Nov 2014 18:26:01 -0200 Subject: [PATCH] this fixes #384; more reading required for a long-term solution--if any --- src/js/pagestore.js | 1 + src/js/traffic.js | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 5ea2fc914..ba56eaf9f 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -308,6 +308,7 @@ PageStore.prototype.init = function(tabId, pageURL) { this.netFilteringReadTime = 0; this.perLoadBlockedRequestCount = 0; this.perLoadAllowedRequestCount = 0; + this.skipLocalMirroring = false; this.netFilteringCache = NetFilteringResultCache.factory(); if ( µb.userSettings.logRequests ) { diff --git a/src/js/traffic.js b/src/js/traffic.js index 34769a0d6..d906d4e20 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -102,19 +102,28 @@ var onBeforeRequest = function(details) { } // https://github.com/gorhill/uBlock/issues/351 - // Bypass experimental features when disabled for a site - if ( µb.userSettings.experimentalEnabled && pageStore.getNetFilteringSwitch() ) { - // https://code.google.com/p/chromium/issues/detail?id=387198 - // Not all redirects will succeed, until bug above is fixed. - var redirectURL = µb.mirrors.toURL(requestURL, true); - if ( redirectURL !== '' ) { - pageStore.setRequestFlags(requestURL, 0x01, 0x01); - //console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50)); - return { redirectUrl: redirectURL }; - } + // Bypass experimental features when uBlock is disabled for a site + if ( !pageStore.getNetFilteringSwitch() ) { + return; + } + + if ( !µb.userSettings.experimentalEnabled ) { + return; + } + + if ( pageStore.skipLocalMirroring ) { + return; + } + + // https://code.google.com/p/chromium/issues/detail?id=387198 + // Not all redirects will succeed, until bug above is fixed. + var redirectURL = µb.mirrors.toURL(requestURL, true); + if ( redirectURL !== '' ) { + pageStore.setRequestFlags(requestURL, 0x01, 0x01); + //console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50)); + return { redirectUrl: redirectURL }; } - //console.debug('µBlock> onBeforeRequest()> ALLOW "%s" (%o)', details.url, details); return; } @@ -236,6 +245,9 @@ var onHeadersReceived = function(details) { return; } + // https://github.com/gorhill/uBlock/issues/384 + pageStore.skipLocalMirroring = headerValue(details.responseHeaders, 'content-security-policy'); + var result = ''; if ( pageStore.getNetFilteringSwitch() ) { result = µb.netFilteringEngine.matchStringExactType(pageStore, details.url, 'inline-script');