mirror of
https://github.com/gorhill/uBlock.git
synced 2024-07-19 03:05:22 +02:00
maybe this will address #150
This commit is contained in:
parent
6c80790975
commit
ff41aed7cf
@ -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]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-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})|((:[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.onModified.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 onModifyListeners = [];
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// 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,8 @@ function parse(text, toAscii) {
|
|||||||
}
|
}
|
||||||
crystallize(exceptions);
|
crystallize(exceptions);
|
||||||
crystallize(rules);
|
crystallize(rules);
|
||||||
|
|
||||||
|
callListeners(onModifyListeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -302,11 +308,39 @@ function fromSelfie(selfie) {
|
|||||||
}
|
}
|
||||||
rules = selfie.rules;
|
rules = selfie.rules;
|
||||||
exceptions = selfie.exceptions;
|
exceptions = selfie.exceptions;
|
||||||
|
callListeners(onModifyListeners);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var callListeners = function(listeners) {
|
||||||
|
for ( var i = 0; i < listeners.length; i++ ) {
|
||||||
|
listeners[i]();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var onModified = {
|
||||||
|
addListener: function(callback) {
|
||||||
|
if (
|
||||||
|
typeof callback === 'function' &&
|
||||||
|
onModifyListeners.indexOf(callback) === -1
|
||||||
|
) {
|
||||||
|
onModifyListeners.push(callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeListener: function(callback) {
|
||||||
|
var pos = onModifyListeners.indexOf(callback);
|
||||||
|
if ( pos !== -1 ) {
|
||||||
|
onModifyListeners.splice(pos, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Public API
|
// Public API
|
||||||
|
|
||||||
root = root || window;
|
root = root || window;
|
||||||
@ -317,7 +351,8 @@ root.publicSuffixList = {
|
|||||||
'getDomain': getDomain,
|
'getDomain': getDomain,
|
||||||
'getPublicSuffix': getPublicSuffix,
|
'getPublicSuffix': getPublicSuffix,
|
||||||
'toSelfie': toSelfie,
|
'toSelfie': toSelfie,
|
||||||
'fromSelfie': fromSelfie
|
'fromSelfie': fromSelfie,
|
||||||
|
'onModified': onModified
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user