Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Nano Linter issues mega thread #1

Open

Description

@jspenguin2017

Filter Linter

Show warning if:

  • Too many or too few arguments are passed in for a script snippet
  • Filter is platform specific and current platform does not support it
  • A script snippet injection rule only have negated domain (it will be converted to an exception rule)
  • A filter will match word boundary but the boundary character is not explicitly given
  • A common mistake is detected

Common mistakes:

  • ||example.com^$generichide - Forgot @@ or important
    It is quite rare that someone want to use important on generichide, chances are he forgot @@.
    Detection logic: If a filter has generhichide but not important and is not an exception filter, then dispatch a warning.
  • /example-path/ - Forgot trailing *
  • /example-path/im - Regular expression flags in procedural cosmetic filters gorhill/uBlock#3372
    When matching part of a path, trailing wildcard is required, otherwise it becomes a RegExp rule.
    Detection logic: If a RegExp rule only contains letters, numbers, -, _, and ., then dispatch a warning.
  • |example.com^ - Missed one |
    Can happen when copying filter, didn't select the whole line.
    Detection logic: For start anchor, if what is anchored does not include protocol, dispatch a warning.
  • ||example.com - Forgot ^
    Although the filter works, it is usually a mistake as it can match example.communicate.example.org.
    Detection logic: If a filter has host name anchor but no ^ nor : nor /, dispatch a warning.
  • example.blogspot.*##element - Wildcard matching half of public suffix
    Filter will not work as expected.
    Detection logic: Could be difficult to implement.

Whitelist Linter

Show warning if:

  • RegExp is used but that is unlikely to be the intent of the user

Activity

  1. modified the milestones: v1.0.2, Future on Dec 7, 2017
  2. changed the title [-]Add filter linter[/-] [+]Nano Linter issues mega thread[/+] on Dec 13, 2017
  3. modified the milestones: Future, v1.0.1 on Dec 23, 2017
  4. jspenguin2017 commented on Dec 29, 2017

    @jspenguin2017
    Author
  5. ameshkov commented on Dec 29, 2017

    @ameshkov
  6. gorhill commented on Dec 29, 2017

    @gorhill
  7. ameshkov commented on Dec 29, 2017

    @ameshkov
  8. gorhill commented on Dec 29, 2017

    @gorhill
  9. jspenguin2017 commented on Dec 29, 2017

    @jspenguin2017
    Author
  10. ameshkov commented on Dec 29, 2017

    @ameshkov
  11. 3 remaining items

  12. grenzor commented on Feb 27, 2018

    @grenzor

    Some Linter issues:

    1. ||example.com^$~document discards the filter and gives a cannot be negated error, but document can be negated and the filter should be valid

    2. @||example.com^ no error is given but filter is missing a @ at the start

    3. ||example.com^,domain=example2.com no error is given but it's an invalid filter

    4. ||example.com^$third-party,$image accidental use of $ for image makes it invalid

    5. x||example.com^ becomes invalid filter due to x, usually due to some typo or accidental copying

    6. example.blogspot.*##element error should be given whenever trying to match partial public suffix. Might also be applicable to other static filter syntax

    7. ||example.com^$third-party,~image,image looks like image block takes precedence over negated. Not sure if some error could be given for this kind of accidental double syntax

  13. jspenguin2017 commented on Feb 27, 2018

    @jspenguin2017
    MemberAuthor

    @grenzor
    The linter is always right when it comes to showing errors since it uses the exact same parsing engine. If it shows error, then the filter is rejected, if it does not show error, then the filter is accepted, although how will the filter behave is another question.

    By design, the linter will never show error if the filter is accepted, but I do agree warnings should be shown for some of these cases. I'll work on that later.

    I think these should generate warning:

    • @||example.com^
    • example.blogspot.*##element
    • ||example.com^$third-party,~image,image

    The error in ||example.com^,domain=example2.com and ||example.com^$third-party,$image are pretty obvious from syntax highlighting, so no extra linter warning is needed. Also, I think x||example.com^ is really unlikely to happen.

  14. grenzor commented on Feb 28, 2018

    @grenzor

    The error in ||example.com^,domain=example2.com and ||example.com^$third-party,$image are pretty obvious from syntax highlighting

    They may be easy to spot if you have a few filters, but for someone with 100s/1000s of their own filters it is not easy at all. It's easier for the user to scroll down and just look at the sidebar for an icon of error or warning than manually checking each line's color syntaxing.

  15. jspenguin2017 commented on Feb 28, 2018

    @jspenguin2017
    MemberAuthor

    @grenzor
    I think you should be writing one filter at a time, and not 1000 then test together. Beside, even if the filter doesn't contain obvious mistake, it doesn't mean it'll work.

  16. grenzor commented on Feb 28, 2018

    @grenzor

    I agree, but my use case was someone with already written filters in uBO who then imported them into Nano.

  17. jspenguin2017 commented on Feb 28, 2018

    @jspenguin2017
    MemberAuthor

    @grenzor
    You should still have validated each filter when you wrote them to make sure they actually work.

  18. jspenguin2017 commented on Mar 2, 2018

    @jspenguin2017
    Author
  19. grenzor commented on Mar 2, 2018

    @grenzor
  20. jspenguin2017 commented on Aug 5, 2018

    @jspenguin2017
    Author
  21. ameshkov commented on Aug 6, 2018

    @ameshkov
  22. jspenguin2017 commented on Aug 10, 2018

    @jspenguin2017
    Author
  23. jspenguin2017 commented on Jul 11, 2020

    @jspenguin2017
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions