mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
Fix spurious leading/trailing wildcards with valid token
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/dpcvfx/
Regression from:
- 7971b22385
Leading/trailing wildcards are useless when a valid
token can be found, and in such case they need to
be removed so as to ensure the proper filter class
is used.
This commit is contained in:
parent
eb23c3581a
commit
7c0294bd5f
@ -2527,6 +2527,25 @@ const FilterParser = class {
|
|||||||
this.token = matches[0];
|
this.token = matches[0];
|
||||||
this.tokenHash = urlTokenizer.tokenHashFromString(this.token);
|
this.tokenHash = urlTokenizer.tokenHashFromString(this.token);
|
||||||
this.tokenBeg = matches.index;
|
this.tokenBeg = matches.index;
|
||||||
|
|
||||||
|
// https://www.reddit.com/r/uBlockOrigin/comments/dpcvfx/
|
||||||
|
// Since we found a valid token, we can get rid of leading/trailing
|
||||||
|
// wildcards if any.
|
||||||
|
if ( this.firstWildcardPos === 0 ) {
|
||||||
|
this.f = this.f.slice(1);
|
||||||
|
this.firstWildcardPos = this.secondWildcardPos;
|
||||||
|
this.secondWildcardPos = -1;
|
||||||
|
}
|
||||||
|
if ( this.firstWildcardPos !== -1 ) {
|
||||||
|
const lastCharPos = this.f.length - 1;
|
||||||
|
if ( this.firstWildcardPos === lastCharPos ) {
|
||||||
|
this.f = this.f.slice(0, -1);
|
||||||
|
this.firstWildcardPos = -1;
|
||||||
|
} else if ( this.secondWildcardPos === lastCharPos ) {
|
||||||
|
this.f = this.f.slice(0, -1);
|
||||||
|
this.secondWildcardPos = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
findGoodToken() {
|
findGoodToken() {
|
||||||
|
Loading…
Reference in New Issue
Block a user