1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Fine tune network filter option anchor detection

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.
This commit is contained in:
Raymond Hill 2023-07-03 06:54:46 -04:00
parent 622cda2cdf
commit e52da39839
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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; }