1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 10:09:38 +02:00

this fixes #384; more reading required for a long-term solution--if any

This commit is contained in:
Raymond Hill 2014-11-29 18:26:01 -02:00
parent 6294dea81d
commit be082cb666
2 changed files with 24 additions and 11 deletions

View File

@ -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 ) {

View File

@ -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');