mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01: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
1 changed files with 9 additions and 22 deletions
|
@ -2213,42 +2213,29 @@ var httpObserver = {
|
|||
|
||||
// contentPolicy.shouldLoad doesn't detect redirects, this needs to be used
|
||||
asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) {
|
||||
var result = this.ACCEPT;
|
||||
|
||||
// If error thrown, the redirect will fail
|
||||
try {
|
||||
var URI = newChannel.URI;
|
||||
|
||||
if ( !URI.schemeIs('http') && !URI.schemeIs('https') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !(oldChannel instanceof Ci.nsIWritablePropertyBag) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
if (
|
||||
oldChannel instanceof Ci.nsIWritablePropertyBag === false ||
|
||||
newChannel instanceof Ci.nsIWritablePropertyBag === false
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Carry the data on in case of multiple redirects
|
||||
if ( newChannel instanceof Ci.nsIWritablePropertyBag ) {
|
||||
newChannel.setProperty(this.REQDATAKEY, channelData);
|
||||
}
|
||||
newChannel.setProperty(
|
||||
this.REQDATAKEY,
|
||||
oldChannel.getProperty(this.REQDATAKEY)
|
||||
);
|
||||
} catch (ex) {
|
||||
// console.error(ex);
|
||||
} finally {
|
||||
callback.onRedirectVerifyCallback(result);
|
||||
callback.onRedirectVerifyCallback(this.ACCEPT);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue