mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-28 02:50:39 +12:00
code review for deeb211c5d
This commit is contained in:
parent
c96fbb4d5c
commit
2d14874d69
|
@ -36,7 +36,8 @@
|
||||||
{
|
{
|
||||||
what: 'securityPolicyViolation',
|
what: 'securityPolicyViolation',
|
||||||
policy: ev.originalPolicy,
|
policy: ev.originalPolicy,
|
||||||
url: ev.documentURI
|
blockedURI: ev.blockedURI,
|
||||||
|
documentURI: ev.documentURI
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -514,6 +514,7 @@ var onMessage = function(request, sender, callback) {
|
||||||
|
|
||||||
var tabId = sender && sender.tab ? sender.tab.id || 0 : 0,
|
var tabId = sender && sender.tab ? sender.tab.id || 0 : 0,
|
||||||
tabContext = µm.tabContextManager.lookup(tabId),
|
tabContext = µm.tabContextManager.lookup(tabId),
|
||||||
|
rootHostname = tabContext && tabContext.rootHostname,
|
||||||
pageStore = µm.pageStoreFromTabId(tabId);
|
pageStore = µm.pageStoreFromTabId(tabId);
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
|
@ -535,8 +536,8 @@ var onMessage = function(request, sender, callback) {
|
||||||
case 'mustRenderNoscriptTags?':
|
case 'mustRenderNoscriptTags?':
|
||||||
if ( tabContext === null ) { break; }
|
if ( tabContext === null ) { break; }
|
||||||
response =
|
response =
|
||||||
µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') &&
|
µm.tMatrix.mustBlock(rootHostname, rootHostname, 'script') &&
|
||||||
µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname);
|
µm.tMatrix.evaluateSwitchZ('noscript-spoof', rootHostname);
|
||||||
if ( pageStore !== null ) {
|
if ( pageStore !== null ) {
|
||||||
pageStore.hasNoscriptTags = true;
|
pageStore.hasNoscriptTags = true;
|
||||||
}
|
}
|
||||||
|
@ -544,25 +545,21 @@ var onMessage = function(request, sender, callback) {
|
||||||
|
|
||||||
case 'securityPolicyViolation':
|
case 'securityPolicyViolation':
|
||||||
if ( request.policy !== µm.cspNoWorkerSrc ) { break; }
|
if ( request.policy !== µm.cspNoWorkerSrc ) { break; }
|
||||||
|
var url = µm.URI.hostnameFromURI(request.blockedURI) !== '' ?
|
||||||
|
request.blockedURI :
|
||||||
|
request.documentURI;
|
||||||
if ( pageStore !== null ) {
|
if ( pageStore !== null ) {
|
||||||
pageStore.hasWebWorkers = true;
|
pageStore.hasWebWorkers = true;
|
||||||
pageStore.recordRequest('script', request.url, true);
|
pageStore.recordRequest('script', url, true);
|
||||||
}
|
}
|
||||||
if ( tabContext !== null ) {
|
if ( tabContext !== null ) {
|
||||||
µm.logger.writeOne(
|
µm.logger.writeOne(tabId, 'net', rootHostname, url, 'worker', true);
|
||||||
tabId,
|
|
||||||
'net',
|
|
||||||
tabContext.rootHostname,
|
|
||||||
request.url,
|
|
||||||
'worker',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'shutdown?':
|
case 'shutdown?':
|
||||||
if ( tabContext !== null ) {
|
if ( tabContext !== null ) {
|
||||||
response = µm.tMatrix.evaluateSwitchZ('matrix-off', tabContext.rootHostname);
|
response = µm.tMatrix.evaluateSwitchZ('matrix-off', rootHostname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ var onHeadersReceived = function(details) {
|
||||||
|
|
||||||
if ( µm.cspNoWorkerSrc === undefined ) {
|
if ( µm.cspNoWorkerSrc === undefined ) {
|
||||||
µm.cspNoWorkerSrc = vAPI.webextFlavor.startsWith('Mozilla-') ?
|
µm.cspNoWorkerSrc = vAPI.webextFlavor.startsWith('Mozilla-') ?
|
||||||
"child-src 'none'; frame-src data: blob: *" :
|
"child-src 'none';frame-src data: blob: *" :
|
||||||
"worker-src 'none'" ;
|
"worker-src 'none'" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ var onHeadersReceived = function(details) {
|
||||||
// A CSP header is already present: just add our own directive as a
|
// A CSP header is already present: just add our own directive as a
|
||||||
// separate disposition (i.e. use comma).
|
// separate disposition (i.e. use comma).
|
||||||
if ( i !== -1 ) {
|
if ( i !== -1 ) {
|
||||||
headers[i].value += ', ' + cspDirectives;
|
headers[i].value += ',' + cspDirectives;
|
||||||
} else {
|
} else {
|
||||||
headers.push({ name: 'Content-Security-Policy', value: cspDirectives });
|
headers.push({ name: 'Content-Security-Policy', value: cspDirectives });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue