Skip to content

Commit

Permalink
Fine tune network filter option anchor detection
Browse files Browse the repository at this point in the history
The change allows to better parse AdGuard filters with `replace=`
option when the value to the `replace=` option contains dollar
sign character `$`. uBO will still reject these filters but will
better identify which dollar sign `$` is the real filter option
anchor.
  • Loading branch information
gorhill committed Jul 3, 2023
1 parent 622cda2 commit e52da39
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/js/static-filtering-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,17 @@ export class AstFilterParser {
if ( j === -1 ) { return end; }
if ( (j+1) === end ) { return end; }
for (;;) {
if ( j !== start && s.charCodeAt(j-1) === 0x24 /* $ */ ) { return -1; }
const c = s.charCodeAt(j+1);
if ( c !== 0x29 /* ) */ && c !== 0x2F /* / */ && c !== 0x7C /* | */ ) { return j; }
const before = s.charCodeAt(j-1);
if ( j !== start && before === 0x24 /* $ */ ) { return -1; }
const after = s.charCodeAt(j+1);
if (
after !== 0x29 /* ) */ &&
after !== 0x2F /* / */ &&
after !== 0x7C /* | */ &&
before !== 0x5C /* \ */
) {
return j;
}
if ( j <= start ) { break; }
j = s.lastIndexOf('$', j-1);
if ( j === -1 ) { break; }
Expand Down

0 comments on commit e52da39

Please sign in to comment.