uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
944 stars 80 forks source link

:matches-path() doesn't work with html filters #2224

Open sn260591 opened 2 years ago

sn260591 commented 2 years ago

Prerequisites

I tried to reproduce the issue when...

Description

See title.

A specific URL where the issue occurs

https://github.com/uBlockOrigin/uBlock-issues

Steps to Reproduce

  1. Add github.com##^:matches-path(/uBlockOrigin) .Header to user filters.
  2. Open https://github.com/uBlockOrigin/uBlock-issues

Expected behavior

The header at the top has been removed.

Actual behavior

The header at the top has not been removed. _

uBlock Origin version

1.44.0

Browser name and version

Firefox 103.0.2

Operating System and version

Windows 7

gwarser commented 2 years ago

I tried on 1.44.1b0 and looks like html filters don't work on any path, only on page root.

I tried h1 html filter on http://example.org/asdf with matches-path - did not work. I tried it without matches-path and it also did not work, but worked on http://example.org/.


Probably because http://example.org/asdf returns 404.

gothic-bum commented 2 years ago

https://github.com/gorhill/uBlock/blob/7bc0b5d2bda39ff0ddb1eb62bb748c239a02d994/src/js/static-filtering-parser.js#L1952

// bit 0: can be used as auto-completion hint
// bit 1: can not be used in HTML filtering
//
Parser.prototype.proceduralOperatorTokens = new Map([
    [ '-abp-contains', 0b00 ],
    [ '-abp-has', 0b00, ],
    [ 'contains', 0b00, ],
    [ 'has', 0b01 ],
    [ 'has-text', 0b01 ],
    [ 'if', 0b00 ],
    [ 'if-not', 0b00 ],
    [ 'matches-css', 0b11 ],
    [ 'matches-css-after', 0b11 ],
    [ 'matches-css-before', 0b11 ],
    [ 'matches-media', 0b11 ],
    [ 'matches-path', 0b11 ],
    [ 'min-text-length', 0b01 ],
    [ 'not', 0b01 ],
    [ 'nth-ancestor', 0b00 ],
    [ 'others', 0b01 ],
    [ 'remove', 0b11 ],
    [ 'style', 0b11 ],
    [ 'upward', 0b01 ],
    [ 'watch-attr', 0b11 ],
    [ 'watch-attrs', 0b00 ],
    [ 'xpath', 0b01 ],
]);
gorhill commented 2 years ago

I did not implement it for HTML filters.