1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 04:49:12 +02:00
No longer need to evaluate within asyncOnChannelRedirect() since
all is now evaluated at `http-on-modify-request` time.
This commit is contained in:
gorhill 2016-06-06 09:51:39 -04:00
parent a5ecf2ed68
commit 76c44e9672

View File

@ -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);
}
}
};