From 93125a466a994797f7c3d81a24a26d4568388f1c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 7 Apr 2022 11:44:07 -0400 Subject: [PATCH] Better highlight bad hostnames in static extended filters Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2080 --- src/js/static-filtering-parser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 78da0744c725c..9932758a35a17 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -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; }