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

uritransform not work if the url contains # #3084

Closed
9 tasks done
MkQtS opened this issue Jan 18, 2024 · 9 comments
Closed
9 tasks done

uritransform not work if the url contains # #3084

MkQtS opened this issue Jan 18, 2024 · 9 comments
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@MkQtS
Copy link

MkQtS commented Jan 18, 2024

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

I want to transfer https://jandan.net/top-ooxx#comment-5611920 into https://jandan.net/t/5611920

I have set 1p-filters as trusted, and added this rule:

||jandan.net/top$uritransform=/top-\w+#comment-/t\//

but it does not work for https://jandan.net/top-ooxx#comment-5611920

I tried to change it to ||jandan.net/top$uritransform=/top-\w+-comment-/t\// (# to -) and open https://jandan.net/top-ooxx-comment-5611920 (an invalid url), then it works.

The problem seems to be related to #. It would be nice if uritransform matches URL hash.

A specific URL where the issue occurs.

https://jandan.net/top-ooxx#comment-5611920

Steps to Reproduce

  1. Add this rule: ||jandan.net/top$uritransform=/top-\w+#comment-/t\//
  2. Open https://jandan.net/top-ooxx#comment-5611920

Expected behavior

The url turns into https://jandan.net/t/5611920

Actual behavior

The url remains https://jandan.net/top-ooxx#comment-5611920

uBO version

1.55.0

Browser name and version

Chrome 120.0

Operating System and version

Windows 11

@gorhill
Copy link
Member

gorhill commented Jan 18, 2024

uritransform currently ignores the hash part of a URL -- I didn't think there would be cases like the one you bring.

I suppose the behavior could be extended to mind the # part.

@gwarser gwarser added the enhancement New feature or request label Jan 18, 2024
gorhill added a commit to gorhill/uBlock that referenced this issue Jan 18, 2024
@u-RraaLL u-RraaLL added the fixed issue has been addressed label Jan 18, 2024
@dimisa-RUAdList
Copy link

dimisa-RUAdList commented Jan 18, 2024

@gorhill
Can you do the same for removeparam?

Example: https://www.rambler.ru/

Screenshot(s)

rambler

||rambler.ru^$removeparam=#rcmrclid

@gorhill
Copy link
Member

gorhill commented Jan 18, 2024

removeparam is too different, it is specifically optimized for query parameters, extending it would undermine efficiency. This was not an issue for uritransform because it doesn't really parse the parts to remove/replace, it's just a string operation. removeparam requires properly parsing and hash is never parsed and decomposed into search parameters.

I suppose a scriptlet could do the job for the hash component, since this information never travels to the server, it's just used client-side.

@dimisa-RUAdList
Copy link

Maybe create a reverse version href-sanitizer? Where the question mark will be responsible for searching and removing the end of the link.

Example: www.rambler.ru##+js(href-sanitizer-rev, a[href^="https://"][href*="#rcmrclid"], ?#rcmrclid)

@MkQtS
Copy link
Author

MkQtS commented Jan 19, 2024

||rambler.ru^$removeparam=#rcmrclid

I think you can use ||rambler.ru^$uritransform=/#rcmrclid=.+// after this update.

Or maybe add a new modifier for URL hash, like ||rambler.ru^$removehash=/rcmrclid=.+/

@krystian3w
Copy link

krystian3w commented Jan 19, 2024

#3084 (comment) - I don't think so, due privilege system?

RU AdList then need addition RUS-0- or own URL-s in advanced settings for list "RU AdList: Counter" (if too popular to add into RUS-0) per user:

https://github.com/gorhill/uBlock/wiki/Advanced-settings#trustedlistprefixes

If will be rejected addition to uBo uAssets Privacy list.


$removehash maybe should work form any file or my filters tab in stable version 1.56.0+

@MkQtS
Copy link
Author

MkQtS commented Jan 19, 2024

I don't think so, due privilege system?

@krystian3w , Do you mean that ||rambler.ru^$uritransform=/#rcmrclid=.+// not works for you?

uritransform won't handle URL hash part until the above commit. With 1.55.1b10+, it should works. I can't verify that, because the dev build on Chrome Web Store is still 1.55.1b7.

$removehash is not existing or planned yet, just a potentially unreasonable assumption of mine.

@stephenhawk8054
Copy link
Member

@MkQtS They mean uritransform is a trusted filter, it won't work if adding it to RuAdlist

@dimisa-RUAdList
Copy link

That's right, I was looking for an opportunity to use those rules that would work from RU AdList, RU AdList: BitBlock, RU AdList: Counters.

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

7 participants