AdguardTeam / AGLint

Universal adblock filter list linter
https://www.npmjs.com/package/@adguard/aglint
MIT License
51 stars 3 forks source link

Add stealth #136

Closed piquark6046 closed 1 year ago

scripthunter7 commented 1 year ago

The other option is to leave the value format field empty for now:

# TODO: validation
# value_format: ...

it will probably be easier and faster to solve these cases with some kind of validator

maximtop commented 1 year ago

Hmm, it looks like JS regexps doesn't support the type of backreference where the pattern can be reused based on the ID of the group, so it marks (?1) group as invalid, therefore the CI fails. regexp101 site uses PHP regexp by default, not JS regexp.

You can only specify a backreference that does not support different values, for example if you give this regexp:

^(?:(searchqueries|donottrack)(\|\1)*)?$

or with named groups

^(?:(?<val>searchqueries|donottrack)(\|\k<val>)*)?$

then these regexps matches with

  • searchqueries
  • donottrack
  • searchqueries|searchqueries
  • donottrack|donottrack

but not with

  • searchqueries|donottrack
  • donottrack|searchqueries

In such cases, unfortunately, the pattern should be defined again, which is redundant, but this is the limitation.

So you should change

^(a|b|c)(\|(?1))$

to

^(a|b|c)(\|(a|b|c))$

(redefine list element pattern again)

@maximtop Do you have a better idea for the regexp?

@scripthunter7 no, I have no other ideas for the regexp, some function for validation sounds like a good solution.