1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-26 04:12:50 +01:00

Improve token extraction from regex-based filters

Tokens which are as long or longer than the max token
length possible do not need to have the prefix part
evaluated against special regex characters. This will
help increase the likelihood of extracting a valid
token from regex-based filters.

Actual case found in EasyPrivacy:

  /^https?:\/\/eulerian..*\/[a-z0-9]{2,12}\.js/$script

Before this commit, uBO was not able to extract a
valid token, while now uBO is able to extract `eulerian`
as a valid token (consequently the regex-based filter
will now be evaluated only when the token `euleria` is
found in a URL).
This commit is contained in:
Raymond Hill 2020-01-09 10:09:51 -05:00
parent 2cf79ef922
commit 8704e4e620
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -2591,8 +2591,12 @@ const FilterParser = class {
const prefix = s.slice(0, matches.index);
if ( this.reRegexTokenAbort.test(prefix) ) { return; }
if (
this.reRegexBadPrefix.test(prefix) ||
this.reRegexBadSuffix.test(s.slice(this.reRegexToken.lastIndex))
this.reRegexBadPrefix.test(prefix) || (
matches[0].length < this.maxTokenLen &&
this.reRegexBadSuffix.test(
s.slice(this.reRegexToken.lastIndex)
)
)
) {
continue;
}