mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 11:22:38 +01:00
Fix broken token extraction
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1367
Regression from:
- 6ac09a2856
Need to mind wildcards adjacent to extracted token.
This commit is contained in:
parent
da01ea4671
commit
dac8d6becb
@ -3152,15 +3152,24 @@ const FilterParser = class {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
const match = this.reToken.exec(pattern);
|
const match = this.reToken.exec(pattern);
|
||||||
if ( match === null ) { break; }
|
if ( match === null ) { break; }
|
||||||
const badness = match[0].length > 1
|
const token = match[0];
|
||||||
? this.badTokens.get(match[0]) || 0
|
const badness = token.length > 1 ? this.badTokens.get(token) || 0 : 1;
|
||||||
: 1;
|
if ( badness >= bestBadness ) { continue; }
|
||||||
if ( badness < bestBadness ) {
|
if ( match.index > 0 ) {
|
||||||
|
const c = pattern.charCodeAt(match.index - 1);
|
||||||
|
if ( c === 0x2A /* '*' */ ) { continue; }
|
||||||
|
}
|
||||||
|
if ( token.length < this.maxTokenLen ) {
|
||||||
|
const lastIndex = this.reToken.lastIndex;
|
||||||
|
if ( lastIndex < pattern.length ) {
|
||||||
|
const c = pattern.charCodeAt(lastIndex);
|
||||||
|
if ( c === 0x2A /* '*' */ ) { continue; }
|
||||||
|
}
|
||||||
|
}
|
||||||
bestMatch = match;
|
bestMatch = match;
|
||||||
if ( badness === 0 ) { break; }
|
if ( badness === 0 ) { break; }
|
||||||
bestBadness = badness;
|
bestBadness = badness;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( bestMatch !== null ) {
|
if ( bestMatch !== null ) {
|
||||||
this.token = bestMatch[0];
|
this.token = bestMatch[0];
|
||||||
this.tokenHash = urlTokenizer.tokenHashFromString(this.token);
|
this.tokenHash = urlTokenizer.tokenHashFromString(this.token);
|
||||||
|
Loading…
Reference in New Issue
Block a user