mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00: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:
parent
2cf79ef922
commit
8704e4e620
1 changed files with 6 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue