mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 01:59:38 +02: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,14 +3152,23 @@ const FilterParser = class {
|
||||
for (;;) {
|
||||
const match = this.reToken.exec(pattern);
|
||||
if ( match === null ) { break; }
|
||||
const badness = match[0].length > 1
|
||||
? this.badTokens.get(match[0]) || 0
|
||||
: 1;
|
||||
if ( badness < bestBadness ) {
|
||||
bestMatch = match;
|
||||
if ( badness === 0 ) { break; }
|
||||
bestBadness = badness;
|
||||
const token = match[0];
|
||||
const badness = token.length > 1 ? this.badTokens.get(token) || 0 : 1;
|
||||
if ( badness >= bestBadness ) { continue; }
|
||||
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;
|
||||
if ( badness === 0 ) { break; }
|
||||
bestBadness = badness;
|
||||
}
|
||||
if ( bestMatch !== null ) {
|
||||
this.token = bestMatch[0];
|
||||
|
Loading…
Reference in New Issue
Block a user