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.
This commit is contained in:
Raymond Hill 2020-03-08 10:55:19 -04:00
parent 30ab587b95
commit 1d9421b8b2
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 1 additions and 1 deletions

View File

@ -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);