1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Better highlight bad hostnames in static extended filters

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2080
This commit is contained in:
Raymond Hill 2022-04-07 11:44:07 -04:00
parent a1788e64bc
commit 93125a466a
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -114,6 +114,7 @@ const Parser = class {
this.reUnicodeChars = /[^\x00-\x7F]/g;
this.reHostnameLabel = /[^.]+/g;
this.rePlainHostname = /^(?:[\w-]+\.)*[a-z]+$/;
this.reBadHostnameChars = /[\x00-\x24\x26-\x29\x2b\x2c\x2f\x3b-\x40\x5c\x5e\x60\x7b-\x7f]/;
this.rePlainEntity = /^(?:[\w-]+\.)+\*$/;
this.reEntity = /^[^*]+\.\*$/;
// https://github.com/uBlockOrigin/uBlock-issues/issues/1146
@ -743,6 +744,7 @@ const Parser = class {
if ( not && (modeBits & 0b1000) === 0 ) { return; }
let hn = not === false ? s : s.slice(1);
if ( this.rePlainHostname.test(hn) ) { return s; }
if ( this.reBadHostnameChars.test(hn) ) { return; }
const hasWildcard = hn.lastIndexOf('*') !== -1;
if ( hasWildcard ) {
if ( modeBits === 0 ) { return; }