mirror of https://github.com/gorhill/uBlock.git
important fixes: #150 + a case where a tab could still be unbound
This commit is contained in:
parent
427659eab2
commit
5205f1474c
|
@ -2173,7 +2173,7 @@ vAPI.onLoadAllCompleted = function() {
|
||||||
|
|
||||||
var tabId = this.tabs.getTabId(tab);
|
var tabId = this.tabs.getTabId(tab);
|
||||||
var browser = getBrowserForTab(tab);
|
var browser = getBrowserForTab(tab);
|
||||||
µb.tabContextManager.commit(tabId, browser.currentURI.asciiSpec);
|
µb.tabContextManager.commit(tabId);
|
||||||
µb.bindTabToPageStats(tabId, browser.currentURI.asciiSpec);
|
µb.bindTabToPageStats(tabId, browser.currentURI.asciiSpec);
|
||||||
browser.messageManager.sendAsyncMessage(
|
browser.messageManager.sendAsyncMessage(
|
||||||
location.host + '-load-completed'
|
location.host + '-load-completed'
|
||||||
|
|
|
@ -88,7 +88,7 @@ return {
|
||||||
|
|
||||||
// read-only
|
// read-only
|
||||||
systemSettings: {
|
systemSettings: {
|
||||||
compiledMagic: 'akjbdyreyxgm',
|
compiledMagic: 'eopszukpnrct',
|
||||||
selfieMagic: 'spqmeuaftfra'
|
selfieMagic: 'spqmeuaftfra'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,10 @@ housekeep itself.
|
||||||
if ( vAPI.isBehindTheSceneTabId(this.tabId) ) {
|
if ( vAPI.isBehindTheSceneTabId(this.tabId) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var count = this.stack.length;
|
||||||
|
if ( count !== 0 && this.stack[count - 1] === url ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.stack.push(url);
|
this.stack.push(url);
|
||||||
this.update();
|
this.update();
|
||||||
};
|
};
|
||||||
|
|
|
@ -287,6 +287,9 @@ var onHeadersReceived = function(details) {
|
||||||
|
|
||||||
return { 'responseHeaders': details.responseHeaders };
|
return { 'responseHeaders': details.responseHeaders };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
var onRootFrameHeadersReceived = function(details) {
|
var onRootFrameHeadersReceived = function(details) {
|
||||||
var tabId = details.tabId;
|
var tabId = details.tabId;
|
||||||
var requestURL = details.url;
|
var requestURL = details.url;
|
||||||
|
@ -297,6 +300,8 @@ var onRootFrameHeadersReceived = function(details) {
|
||||||
// ...
|
// ...
|
||||||
if ( headerValue(details.responseHeaders, 'content-disposition').lastIndexOf('attachment', 0) === 0 ) {
|
if ( headerValue(details.responseHeaders, 'content-disposition').lastIndexOf('attachment', 0) === 0 ) {
|
||||||
µb.tabContextManager.unpush(tabId, requestURL);
|
µb.tabContextManager.unpush(tabId, requestURL);
|
||||||
|
} else {
|
||||||
|
µb.tabContextManager.push(tabId, requestURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup the page store associated with this tab id.
|
// Lookup the page store associated with this tab id.
|
||||||
|
@ -304,7 +309,6 @@ var onRootFrameHeadersReceived = function(details) {
|
||||||
if ( !pageStore ) {
|
if ( !pageStore ) {
|
||||||
pageStore = µb.bindTabToPageStats(tabId, 'beforeRequest');
|
pageStore = µb.bindTabToPageStats(tabId, 'beforeRequest');
|
||||||
}
|
}
|
||||||
// I can't think of how pageStore could be null at this point.
|
|
||||||
|
|
||||||
var context = pageStore.createContextFromPage();
|
var context = pageStore.createContextFromPage();
|
||||||
context.requestURL = requestURL + '{inline-script}';
|
context.requestURL = requestURL + '{inline-script}';
|
||||||
|
|
|
@ -72,10 +72,10 @@ var reIPAddressNaive = /^\d+\.\d+\.\d+\.\d+$|^\[[\da-zA-Z:]+\]$/;
|
||||||
|
|
||||||
// Accurate tests
|
// Accurate tests
|
||||||
// Source.: http://stackoverflow.com/questions/5284147/validating-ipv4-addresses-with-regexp/5284410#5284410
|
// Source.: http://stackoverflow.com/questions/5284147/validating-ipv4-addresses-with-regexp/5284410#5284410
|
||||||
var reIPv4 = /^((25[0-5]|2[0-4]\d|[01]?\d\d?)(\.|$)){4}/;
|
//var reIPv4 = /^((25[0-5]|2[0-4]\d|[01]?\d\d?)(\.|$)){4}/;
|
||||||
|
|
||||||
// Source: http://forums.intermapper.com/viewtopic.php?p=1096#1096
|
// Source: http://forums.intermapper.com/viewtopic.php?p=1096#1096
|
||||||
var reIPv6 = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|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7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -366,11 +366,18 @@ var domainCachePrune = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var domainCacheReset = function() {
|
||||||
|
domainCache = {};
|
||||||
|
domainCacheCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
var domainCache = {};
|
var domainCache = {};
|
||||||
var domainCacheCount = 0;
|
var domainCacheCount = 0;
|
||||||
var domainCacheCountLowWaterMark = 75;
|
var domainCacheCountLowWaterMark = 75;
|
||||||
var domainCacheCountHighWaterMark = 100;
|
var domainCacheCountHighWaterMark = 100;
|
||||||
|
|
||||||
|
psl.onChanged.addListener(domainCacheReset);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
URI.domainFromURI = function(uri) {
|
URI.domainFromURI = function(uri) {
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
;(function(root) {
|
;(function(root) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var exceptions = {};
|
var exceptions = {};
|
||||||
|
@ -45,6 +47,8 @@ var selfieMagic = 'iscjsfsaolnm';
|
||||||
var cutoffLength = 256;
|
var cutoffLength = 256;
|
||||||
var mustPunycode = /[^a-z0-9.-]/;
|
var mustPunycode = /[^a-z0-9.-]/;
|
||||||
|
|
||||||
|
var onChangedListeners = [];
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// In the context of this code, a domain is defined as:
|
// In the context of this code, a domain is defined as:
|
||||||
|
@ -234,6 +238,7 @@ function parse(text, toAscii) {
|
||||||
}
|
}
|
||||||
crystallize(exceptions);
|
crystallize(exceptions);
|
||||||
crystallize(rules);
|
crystallize(rules);
|
||||||
|
callListeners(onChangedListeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -302,11 +307,47 @@ function fromSelfie(selfie) {
|
||||||
}
|
}
|
||||||
rules = selfie.rules;
|
rules = selfie.rules;
|
||||||
exceptions = selfie.exceptions;
|
exceptions = selfie.exceptions;
|
||||||
|
callListeners(onChangedListeners);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var addListener = function(listeners, callback) {
|
||||||
|
if ( typeof callback !== 'function' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( listeners.indexOf(callback) === -1 ) {
|
||||||
|
listeners.push(callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var removeListener = function(listeners, callback) {
|
||||||
|
var pos = listeners.indexOf(callback);
|
||||||
|
if ( pos !== -1 ) {
|
||||||
|
listeners.splice(pos, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var callListeners = function(listeners) {
|
||||||
|
for ( var i = 0; i < listeners.length; i++ ) {
|
||||||
|
listeners[i]();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var onChanged = {
|
||||||
|
addListener: function(callback) {
|
||||||
|
addListener(onChangedListeners, callback);
|
||||||
|
},
|
||||||
|
removeListener: function(callback) {
|
||||||
|
removeListener(onChangedListeners, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Public API
|
// Public API
|
||||||
|
|
||||||
root = root || window;
|
root = root || window;
|
||||||
|
@ -317,7 +358,8 @@ root.publicSuffixList = {
|
||||||
'getDomain': getDomain,
|
'getDomain': getDomain,
|
||||||
'getPublicSuffix': getPublicSuffix,
|
'getPublicSuffix': getPublicSuffix,
|
||||||
'toSelfie': toSelfie,
|
'toSelfie': toSelfie,
|
||||||
'fromSelfie': fromSelfie
|
'fromSelfie': fromSelfie,
|
||||||
|
'onChanged': onChanged
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue