Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new rule to validate network rule patterns #196

Open
Alex-302 opened this issue Jan 26, 2024 · 2 comments
Open

Add a new rule to validate network rule patterns #196

Alex-302 opened this issue Jan 26, 2024 · 2 comments

Comments

@Alex-302
Copy link
Member

Alex-302 commented Jan 26, 2024

Incorrect usage of |, || is not detected, for example - |||
image

  • Invalid rules
    |||example.com^ - should be ||
    https://example.com/ads.js|| - should be | at the end

  • Redundant characters

  • ||example.com/ads**.js|| - one * is enough, **+ - redundant

  • ||*/banners/*$domain=example.com - ||* / |* at the beginning of non-domain like of URL part. In this example one * is required to make the rule non-regexp style (usually at the end).

@scripthunter7
Copy link
Member

scripthunter7 commented Jan 26, 2024

We also need to validate the use of the * and ^ characters. Also the start and end pointers (|)

Reference:

@ameshkov @maximtop In the longer term, perhaps we should parse the network rule patterns. Thus, using || incorrectly or using a space/invalid chars within the pattern would result a syntax error. Moreover, the pattern could be fragmented, e.g. like this:
||example.com/*.js^ -> ['||', 'example.com/', '*', '.js', '^']

@scripthunter7
Copy link
Member

Unnecessary spaces
AdguardTeam/AdguardFilters@cf07657

Originally posted by @piquark6046 in #13 (comment)

@scripthunter7 scripthunter7 changed the title Validate network rule patterns Add a new rule to validate network rule patterns Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants