mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-02 18:34:52 +12:00
This commit is contained in:
parent
ae894fb571
commit
494cd9e95c
|
@ -122,26 +122,31 @@ var onBeforeRequestHandler = function(details) {
|
||||||
let tabContext = µm.tabContextManager.mustLookup(details.tabId),
|
let tabContext = µm.tabContextManager.mustLookup(details.tabId),
|
||||||
tabId = tabContext.tabId,
|
tabId = tabContext.tabId,
|
||||||
srcHn = tabContext.rootHostname,
|
srcHn = tabContext.rootHostname,
|
||||||
|
desHn = µmuri.hostnameFromURI(desURL),
|
||||||
|
docURL = details.documentUrl,
|
||||||
specificity = 0;
|
specificity = 0;
|
||||||
|
|
||||||
// https://github.com/gorhill/uMatrix/issues/995
|
if ( docURL !== undefined ) {
|
||||||
// For now we will not reclassify behind-the-scene contexts which are not
|
// https://github.com/gorhill/uMatrix/issues/995
|
||||||
// network-based URIs. Once the logger is able to provide context
|
// For now we will not reclassify behind-the-scene contexts which
|
||||||
// information, the reclassification will be allowed.
|
// are not network-based URIs. Once the logger is able to provide
|
||||||
if (
|
// context information, the reclassification will be allowed.
|
||||||
tabId < 0 &&
|
if ( tabId < 0 ) {
|
||||||
details.documentUrl !== undefined &&
|
srcHn = µmuri.hostnameFromURI(µm.normalizePageURL(0, docURL));
|
||||||
µmuri.isNetworkURI(details.documentUrl)
|
}
|
||||||
) {
|
// https://github.com/uBlockOrigin/uMatrix-issues/issues/72
|
||||||
tabId = µm.tabContextManager.tabIdFromURL(details.documentUrl);
|
// Workaround of weird Firefox behavior: when a service worker exists
|
||||||
srcHn = µmuri.hostnameFromURI(
|
// for a site, the `doc` requests when loading a page from that site
|
||||||
µm.normalizePageURL(0, details.documentUrl)
|
// are not being made: this potentially prevents uMatrix to properly
|
||||||
);
|
// keep track of the context in which requests are made.
|
||||||
|
else if (
|
||||||
|
details.parentFrameId === -1 &&
|
||||||
|
docURL !== tabContext.rawURL
|
||||||
|
) {
|
||||||
|
srcHn = µmuri.hostnameFromURI(µm.normalizePageURL(0, docURL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter through matrix
|
|
||||||
let desHn = µmuri.hostnameFromURI(desURL);
|
|
||||||
|
|
||||||
let blocked = µm.tMatrix.mustBlock(srcHn, desHn, type);
|
let blocked = µm.tMatrix.mustBlock(srcHn, desHn, type);
|
||||||
if ( blocked ) {
|
if ( blocked ) {
|
||||||
specificity = µm.tMatrix.specificityRegister;
|
specificity = µm.tMatrix.specificityRegister;
|
||||||
|
@ -196,6 +201,8 @@ var onBeforeSendHeadersHandler = function(details) {
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275
|
// https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275
|
||||||
let tabId = details.tabId,
|
let tabId = details.tabId,
|
||||||
pageStore = µm.mustPageStoreFromTabId(tabId),
|
pageStore = µm.mustPageStoreFromTabId(tabId),
|
||||||
|
srcHn = pageStore.pageHostname,
|
||||||
|
desHn = µmuri.hostnameFromURI(desURL),
|
||||||
requestType = requestTypeNormalizer[details.type] || 'other',
|
requestType = requestTypeNormalizer[details.type] || 'other',
|
||||||
requestHeaders = details.requestHeaders;
|
requestHeaders = details.requestHeaders;
|
||||||
|
|
||||||
|
@ -226,7 +233,7 @@ var onBeforeSendHeadersHandler = function(details) {
|
||||||
if ( headerValue !== '' ) {
|
if ( headerValue !== '' ) {
|
||||||
let blocked = µm.userSettings.processHyperlinkAuditing;
|
let blocked = µm.userSettings.processHyperlinkAuditing;
|
||||||
pageStore.recordRequest('other', desURL + '{Ping-To:' + headerValue + '}', blocked);
|
pageStore.recordRequest('other', desURL + '{Ping-To:' + headerValue + '}', blocked);
|
||||||
µm.logger.writeOne({ tabId, desURL, type: 'ping', blocked });
|
µm.logger.writeOne({ tabId, srcHn, desHn, desURL, type: 'ping', blocked });
|
||||||
if ( blocked ) {
|
if ( blocked ) {
|
||||||
µm.hyperlinkAuditingFoiledCounter += 1;
|
µm.hyperlinkAuditingFoiledCounter += 1;
|
||||||
return { 'cancel': true };
|
return { 'cancel': true };
|
||||||
|
@ -237,9 +244,7 @@ var onBeforeSendHeadersHandler = function(details) {
|
||||||
// If we reach this point, request is not blocked, so what is left to do
|
// If we reach this point, request is not blocked, so what is left to do
|
||||||
// is to sanitize headers.
|
// is to sanitize headers.
|
||||||
|
|
||||||
let srcHn = pageStore.pageHostname,
|
let modified = false;
|
||||||
desHn = µmuri.hostnameFromURI(desURL),
|
|
||||||
modified = false;
|
|
||||||
|
|
||||||
// Process `Cookie` header.
|
// Process `Cookie` header.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue