From de88721132eb22f118a015d214073554714457a4 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 18 Jan 2015 19:17:36 -0500 Subject: [PATCH] Re. #540: disabling local mirroring for the time being --- src/js/storage.js | 5 +++++ src/js/traffic.js | 34 +++++++++++++++++++++++++--------- src/js/ublock.js | 4 +++- src/settings.html | 2 +- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index dcca33ddc..aec5a98f5 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -658,7 +658,12 @@ µb.assets.allowRemoteFetch = false; µb.assets.autoUpdate = userSettings.autoUpdate; µb.fromSelfie(onSelfieReady); + + // https://github.com/gorhill/uBlock/issues/540 + // Disabling local mirroring for the time being + userSettings.experimentalEnabled = false; µb.mirrors.toggle(userSettings.experimentalEnabled); + µb.contextMenu.toggle(userSettings.contextMenuEnabled); µb.dynamicNetFilteringEngine.fromString(userSettings.dynamicFilteringString); diff --git a/src/js/traffic.js b/src/js/traffic.js index cc77076bf..ed6e3995e 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -120,13 +120,14 @@ var onBeforeRequest = function(details) { // https://code.google.com/p/chromium/issues/detail?id=387198 // Not all redirects will succeed, until bug above is fixed. - var redirectURL = pageStore.toMirrorURL(requestURL); - if ( redirectURL !== '' ) { - pageStore.logBuffer.writeOne(requestContext, 'ma:'); - + // https://github.com/gorhill/uBlock/issues/540 + // Disabling local mirroring for the time being + //var redirectURL = pageStore.toMirrorURL(requestURL); + //if ( redirectURL !== '' ) { + // pageStore.logBuffer.writeOne(requestContext, 'ma:'); //console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50)); - return { redirectUrl: redirectURL }; - } + // return { redirectUrl: redirectURL }; + //} pageStore.logBuffer.writeOne(requestContext, result); @@ -251,9 +252,11 @@ var onHeadersReceived = function(details) { } // https://github.com/gorhill/uBlock/issues/384 - if ( details.parentFrameId === -1 ) { - pageStore.skipLocalMirroring = headerValue(details.responseHeaders, 'content-security-policy'); - } + // https://github.com/gorhill/uBlock/issues/540 + // Disabling local mirroring for the time being + //if ( details.parentFrameId === -1 ) { + // pageStore.skipLocalMirroring = headerStartWith(details.responseHeaders, 'content-security-policy') !== ''; + //} var requestURL = details.url; var requestHostname = µb.URI.hostnameFromURI(requestURL); @@ -321,6 +324,19 @@ var headerValue = function(headers, name) { /******************************************************************************/ +var headerStartWith = function(headers, prefix) { + var prefixLen = prefix.length; + var i = headers.length; + while ( i-- ) { + if ( headers[i].name.slice(0, prefixLen).toLowerCase() === prefix ) { + return headers[i].value; + } + } + return ''; +}; + +/******************************************************************************/ + vAPI.net.onBeforeRequest = { urls: [ 'http://*/*', diff --git a/src/js/ublock.js b/src/js/ublock.js index a0be4c09d..ac4bd2397 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -267,7 +267,9 @@ var matchWhitelistDirective = function(url, hostname, directive) { break; case 'experimentalEnabled': if ( typeof this.mirrors === 'object' ) { - this.mirrors.toggle(value); + // https://github.com/gorhill/uBlock/issues/540 + // Disabling local mirroring for the time being + this.mirrors.toggle(false /* value */); } break; default: diff --git a/src/settings.html b/src/settings.html index fa5fb1e2b..fe376538c 100644 --- a/src/settings.html +++ b/src/settings.html @@ -24,7 +24,7 @@ ul {
  • -
  • +