mirror of https://github.com/gorhill/uBlock.git
fix #3606
This commit is contained in:
parent
f2ad4144e0
commit
8f1b4b52fd
|
@ -422,16 +422,6 @@
|
||||||
let reHostnameVeryCoarse = /[g-z_-]/;
|
let reHostnameVeryCoarse = /[g-z_-]/;
|
||||||
let reIPv4VeryCoarse = /\.\d+$/;
|
let reIPv4VeryCoarse = /\.\d+$/;
|
||||||
|
|
||||||
let isIPAddress = function(hostname) {
|
|
||||||
if ( reHostnameVeryCoarse.test(hostname) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ( reIPv4VeryCoarse.test(hostname) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return hostname.startsWith('[');
|
|
||||||
};
|
|
||||||
|
|
||||||
let toBroaderHostname = function(hostname) {
|
let toBroaderHostname = function(hostname) {
|
||||||
let pos = hostname.indexOf('.');
|
let pos = hostname.indexOf('.');
|
||||||
if ( pos !== -1 ) {
|
if ( pos !== -1 ) {
|
||||||
|
@ -440,15 +430,30 @@
|
||||||
return hostname !== '*' && hostname !== '' ? '*' : '';
|
return hostname !== '*' && hostname !== '' ? '*' : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
let toBroaderIPAddress = function(ipaddress) {
|
let toBroaderIPv4Address = function(ipaddress) {
|
||||||
|
if ( ipaddress === '*' || ipaddress === '' ) { return ''; }
|
||||||
|
let pos = ipaddress.lastIndexOf('.');
|
||||||
|
if ( pos === -1 ) { return '*'; }
|
||||||
|
return ipaddress.slice(0, pos);
|
||||||
|
};
|
||||||
|
|
||||||
|
let toBroaderIPv6Address = function(ipaddress) {
|
||||||
return ipaddress !== '*' && ipaddress !== '' ? '*' : '';
|
return ipaddress !== '*' && ipaddress !== '' ? '*' : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
return function decomposeHostname(hostname, decomposed) {
|
return function decomposeHostname(hostname, decomposed) {
|
||||||
if ( decomposed.length === 0 || decomposed[0] !== hostname ) {
|
if ( decomposed.length === 0 || decomposed[0] !== hostname ) {
|
||||||
let broaden = isIPAddress(hostname) ?
|
let broaden;
|
||||||
toBroaderIPAddress :
|
if ( reHostnameVeryCoarse.test(hostname) === false ) {
|
||||||
toBroaderHostname;
|
if ( reIPv4VeryCoarse ) {
|
||||||
|
broaden = toBroaderIPv4Address;
|
||||||
|
} else if ( hostname.startsWith('[') ) {
|
||||||
|
broaden = toBroaderIPv6Address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( broaden === undefined ) {
|
||||||
|
broaden = toBroaderHostname;
|
||||||
|
}
|
||||||
decomposed[0] = hostname;
|
decomposed[0] = hostname;
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
Loading…
Reference in New Issue