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

Cannot use redirect option with negated domain #310

Closed
8 tasks done
Jtasiu opened this issue Nov 23, 2018 · 17 comments
Closed
8 tasks done

Cannot use redirect option with negated domain #310

Jtasiu opened this issue Nov 23, 2018 · 17 comments
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@Jtasiu
Copy link

Jtasiu commented Nov 23, 2018

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

I am writing some filters but I noticed the below kind didn't work

*pop.js$important,script,redirect=noopjs,domain=~site.com

Why negated domains don't work at all with redirect option? I would like to create filters to do this as I don't mind performance hit, can deal with breakage myself and would rather redirect some file names totally. Is it possible to add a way to do this?

@gwarser gwarser added the bug Something isn't working label Nov 23, 2018
@gwarser
Copy link

gwarser commented Nov 23, 2018

Seems to work for a.com|~b.com and other way around, but not for simple ~a.com (no redirection at all)

Tested on https://www.wykop.pl/ and https://www.wp.pl/ with variants of */xgemius.js$script,redirect=noopjs,domain=wp.pl|~wykop.pl

@uBlock-user
Copy link
Contributor

another limitation of redirect directive it seems..

@gorhill
Copy link
Member

gorhill commented Nov 23, 2018

The issue is that redirect= should have been made to strictly create redirection directives, not blocking filters -- I keep repeating this.

The issue here can be solved only if changing all the semantic of the redirect= filters, which of course can't happen. OP's issue can be resolved by overriding the blanket redirection with another filter.

@uBlock-user
Copy link
Contributor

The issue here can be solved only if changing all the semantic of the redirect= filters, which of course can't happen.

So this is a won't fix ?

@gorhill
Copy link
Member

gorhill commented Nov 23, 2018

So this is a won't fix ?

I could make the filter *pop.js$important,script,redirect=noopjs,domain=~site.com work, but it would have to be understood that if ever a network request of type script from site.com pattern-matching pop.js is ever blocked by whatever mean, it would be redirected to noopjs.

@uBlock-user
Copy link
Contributor

uBlock-user commented Nov 23, 2018

You mean except from site.com ? as thats negated.

@gorhill
Copy link
Member

gorhill commented Nov 23, 2018

I meant what I wrote.

@uBlock-user
Copy link
Contributor

Why would it apply on the negated domain ?

@gwarser
Copy link

gwarser commented Nov 23, 2018

Filter will be split into two parts: blocking part and redirecting. Negation will disable blocking. Blocking by any other means/filters will trigger redirection.

@uBlock-user
Copy link
Contributor

uBlock-user commented Nov 23, 2018

Wouldn't negation affect redirection too ? If that's the case, then there's no point in adding a negated domain with redirection.

@Jtasiu
Copy link
Author

Jtasiu commented Nov 25, 2018

@gwarser

Seems to work for a.com|~b.com and other way around, but not for simple ~a.com (no redirection at all)

Don't think the filter you wrote works for negated...to me looks like a.com will follow the filter rule but the negated domain will not work with the filter (it will be discarded).

@gorhill

OP's issue can be resolved by overriding the blanket redirection with another filter.

Not sure what that another filter is...please post example?

gorhill added a commit to gorhill/uBlock that referenced this issue Aug 3, 2019
Related issue:
- uBlockOrigin/uBlock-issues#310

The purpose of this new option is to add the ability
to create standalone redirect rule without being forced
to create a block filter (a corresponding block filter
is always created when using the `redirect=`).

Additionally:

The syntax `*$redirect=token,...` is now supported, there
is no need to "trick" the filter parser with
`*/*$redirect=token,...` in order to create redirect rules
which are meant to match all paths.

Filters of the form `|http*://` will be normalized into
two corresponding filters `|https://` and `|http://` so as
to reduce the number of filters in the buckets of
untokenizable filters.
@uBlockOrigin uBlockOrigin deleted a comment from prateekrastogi Jan 26, 2020
@gorhill gorhill added wontfix won't be addressed and removed bug Something isn't working labels Jul 23, 2020
@gorhill
Copy link
Member

gorhill commented Jul 23, 2020

I am going to decline this, using negated domains with redirect option is ambiguous. In case of ambiguity, use two separate filters, one for blocking, one for redirecting with redirect-rule=.

@gorhill gorhill closed this as completed Jul 23, 2020
@gwarser
Copy link

gwarser commented Sep 6, 2020

How to create global redirect rule and then disable it on one domain?

@gwarser
Copy link

gwarser commented Sep 6, 2020

on https://github.com/uBlockOrigin/uBlock-issues/wiki/Static-filter-syntax

assets/wiki-b38a80ef.js$script,redirect=noop.js
assets/wiki-b38a80ef.js$script,redirect=none,domain=github.com

@uBlock-user
Copy link
Contributor

assets/wiki-b38a80ef.js$script,redirect=noop.js
assets/wiki-b38a80ef.js$script,redirect-rule=none,domain=github.com

Like that

@gwarser
Copy link

gwarser commented Nov 25, 2020

Should be fixed by gorhill/uBlock@157cef6


Tested by

! */xgemius.js$script,redirect=noopjs,domain=~wp.pl|wykop.pl
! */xgemius.js$script,redirect=noopjs,domain=wp.pl|~wykop.pl
! */xgemius.js$script,redirect=noopjs,domain=~wykop.pl
*/xgemius.js$script,redirect=noopjs,domain=~wp.pl

one by one and works fine.

@gwarser gwarser added enhancement New feature or request fixed issue has been addressed and removed wontfix won't be addressed labels Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

4 participants