1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

code review of fix to #2360

This commit is contained in:
gorhill 2017-02-07 08:05:39 -05:00
parent 48b3ba161b
commit 7176ecb3e7

View File

@ -430,28 +430,29 @@ var processCSP = function(pageStore, details) {
loggerEnabled = µb.logger.isEnabled(); loggerEnabled = µb.logger.isEnabled();
var context = pageStore.createContextFromPage(); var context = pageStore.createContextFromPage();
context.requestURL = requestURL;
context.requestHostname = µb.URI.hostnameFromURI(requestURL); context.requestHostname = µb.URI.hostnameFromURI(requestURL);
if ( details.type !== 'main_frame' ) { if ( details.type !== 'main_frame' ) {
context.pageHostname = context.pageDomain = context.requestHostname; context.pageHostname = context.pageDomain = context.requestHostname;
} }
var inlineScriptResult, blockInlineScript; var inlineScriptResult, blockInlineScript,
workerResult, blockWorker;
if ( details.type !== 'script' ) { if ( details.type !== 'script' ) {
context.requestType = 'inline-script'; context.requestType = 'inline-script';
context.requestURL = requestURL;
inlineScriptResult = pageStore.filterRequestNoCache(context); inlineScriptResult = pageStore.filterRequestNoCache(context);
blockInlineScript = µb.isBlockResult(inlineScriptResult); blockInlineScript = µb.isBlockResult(inlineScriptResult);
// https://github.com/gorhill/uBlock/issues/2360
context.requestType = 'script';
context.requestURL = 'blob:';
workerResult = pageStore.filterRequestNoCache(context);
blockWorker = µb.isBlockResult(workerResult);
} }
µb.staticNetFilteringEngine.matchStringExactType(context, requestURL, 'websocket'); µb.staticNetFilteringEngine.matchStringExactType(context, requestURL, 'websocket');
var websocketResult = µb.staticNetFilteringEngine.toResultString(loggerEnabled), var websocketResult = µb.staticNetFilteringEngine.toResultString(loggerEnabled),
blockWebsocket = µb.isBlockResult(websocketResult); blockWebsocket = µb.isBlockResult(websocketResult);
// https://github.com/gorhill/uBlock/issues/2360
µb.staticNetFilteringEngine.matchStringExactType(context, 'blob:', 'script');
var workerResult = µb.staticNetFilteringEngine.toResultString(loggerEnabled),
blockWorker = µb.isBlockResult(workerResult);
var headersChanged; var headersChanged;
if ( blockInlineScript || blockWebsocket || blockWorker ) { if ( blockInlineScript || blockWebsocket || blockWorker ) {
headersChanged = foilWithCSP( headersChanged = foilWithCSP(