mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
code review re. https://github.com/gorhill/uMatrix/issues/554
No longer need to evaluate within asyncOnChannelRedirect() since all is now evaluated at `http-on-modify-request` time.
This commit is contained in:
parent
a5ecf2ed68
commit
76c44e9672
@ -2213,42 +2213,29 @@ var httpObserver = {
|
|||||||
|
|
||||||
// contentPolicy.shouldLoad doesn't detect redirects, this needs to be used
|
// contentPolicy.shouldLoad doesn't detect redirects, this needs to be used
|
||||||
asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) {
|
asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) {
|
||||||
var result = this.ACCEPT;
|
|
||||||
|
|
||||||
// If error thrown, the redirect will fail
|
// If error thrown, the redirect will fail
|
||||||
try {
|
try {
|
||||||
var URI = newChannel.URI;
|
var URI = newChannel.URI;
|
||||||
|
|
||||||
if ( !URI.schemeIs('http') && !URI.schemeIs('https') ) {
|
if ( !URI.schemeIs('http') && !URI.schemeIs('https') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(oldChannel instanceof Ci.nsIWritablePropertyBag) ) {
|
if (
|
||||||
return;
|
oldChannel instanceof Ci.nsIWritablePropertyBag === false ||
|
||||||
}
|
newChannel instanceof Ci.nsIWritablePropertyBag === false
|
||||||
|
) {
|
||||||
var channelData = oldChannel.getProperty(this.REQDATAKEY);
|
|
||||||
|
|
||||||
var details = {
|
|
||||||
frameId: channelData[0],
|
|
||||||
parentFrameId: channelData[1],
|
|
||||||
tabId: channelData[2],
|
|
||||||
rawtype: channelData[3]
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( this.handleRequest(newChannel, URI, details) ) {
|
|
||||||
result = this.ABORT;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carry the data on in case of multiple redirects
|
// Carry the data on in case of multiple redirects
|
||||||
if ( newChannel instanceof Ci.nsIWritablePropertyBag ) {
|
newChannel.setProperty(
|
||||||
newChannel.setProperty(this.REQDATAKEY, channelData);
|
this.REQDATAKEY,
|
||||||
}
|
oldChannel.getProperty(this.REQDATAKEY)
|
||||||
|
);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// console.error(ex);
|
// console.error(ex);
|
||||||
} finally {
|
} finally {
|
||||||
callback.onRedirectVerifyCallback(result);
|
callback.onRedirectVerifyCallback(this.ACCEPT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user