From 1d9421b8b2d7b094fd3b04dbce25a726dc678f55 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 8 Mar 2020 10:55:19 -0400 Subject: [PATCH] Improve validation of CSS selector-based cosmetic filters Reported internally. The following invalid filter was not discarded by uBO: 123tvnow.com##.123tv-ads The correct form should be: 123tvnow.com##.\31 23tv-ads Not discarding invalid CSS selector-based cosmetic filter may break CSS selector-based cosmetic filtering. --- src/js/static-ext-filtering.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/static-ext-filtering.js b/src/js/static-ext-filtering.js index 2de1e29f0..c855f3638 100644 --- a/src/js/static-ext-filtering.js +++ b/src/js/static-ext-filtering.js @@ -98,7 +98,7 @@ } // Quick regex-based validation -- most cosmetic filters are of the // simple form and in such case a regex is much faster. - const reSimple = /^[#.][\w-]+$/; + const reSimple = /^[#.][A-Za-z_][\w-]*$/; return s => { if ( reSimple.test(s) ) { return 1; } const pos = cssPseudoSelector(s);