brave/adblock-rust

Support uBO redirect rules

Closed this issue · 1 comments

From: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#redirect

  1. A filter with redirect blocks and redirects the mentioned request.
  2. A filter with redirect-rule only redirects the mentioned request if it is blocked by any other filter.
    "redirect is internally translated to redirect-rule"

Testcase: https://turreta.com/2020/11/14/rust-array-size-limit-to-32-no-more-in-1-47-0-release/
Affected filter: ||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,redirect-rule=googlesyndication_adsbygoogle.js

Currently only working around with @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=turreta.com

376 redirect-rule filters in uAssets.

We have a few workarounds in unbreak: https://github.com/brave/adblock-lists/blob/master/brave-unbreak.txt#L256

Keeping track of implementation here:

  • DAT packager side, begin duplicating any redirect filter, and adding it to Blocker::redirects. This should not change any behavior for existing clients (#185).
  • When updated DATs are available, begin treating redirects as independent from blocking/exception filters. This means exceptions for blocking should only be looked for in Blocker::exceptions, and exceptions for redirections should only be looked for in Blocker::redirects. Blocker::redirects should be checked for all matches rather than the first match (similar to $csp), and results should be combined accordingly. At this point, a redirection exception should always occur whenever a blocking exception occurs, but the code should be ready to handle the case when they do not occur together (#184).
  • Once clients have updated sufficiently, support for redirect-rule can be added on the DAT packager side. These will be added only to Blocker::redirects (#219).
  • Support can be added for redirect-rule=resource:[priority] syntax (#222).