Skip to content

urlskip with multiple regexes doesn't work #3914

@nihaals

Description

@nihaals

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

If a urlskip has multiple regexes, the second and beyond instances will be replaced with the first. This is due to a cache:
https://github.com/gorhill/uBlock/blob/74b838cc0367fc3d5d2e538325f9d85eec71615c/src/js/urlskip.js#L134-L138

I've confirmed in a debugger and this is definitely what's happening.

A specific URL where the issue occurs.

https://links.vinted.com/e/t/aHR0cHM6Ly93d3cudmludGVkLmNvLnVrL2UvaXRlbT9pZD0xMjM0NTY3ODkwfDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMHxBMGFhYUFhYV9BMEEwQWFhQUFBYUFhQTAtYUFhYTBhYUFBQUFBQWFhQUFhPQ==

Steps to Reproduce

  1. Add a filter ||links.vinted.com/e/t/$document
  2. Add a filter ||links.vinted.com$document,urlskip=/\/e\/t\/([A-Za-z0-9=]+)/ -base64 /^(.*?)\|/
  3. Go to the reproduction URL (matches the pattern of a real URL perfectly but anonymised)
  4. Notice the link is blocked but no redirect URL is shown
  5. Edit the second filter to ||links.vinted.com$document,urlskip=/\/e\/t\/([A-Za-z0-9=]+)/ -base64
  6. Notice a redirect URL is shown
  7. Notice the second regex should work fine
  8. Revert to the original second filter, set a breakpoint on https://github.com/gorhill/uBlock/blob/74b838cc0367fc3d5d2e538325f9d85eec71615c/src/js/urlskip.js#L135 and notice /\/e\/t\/([A-Za-z0-9=]+)/ is used twice

Expected behavior

A redirect URL is shown of https://www.vinted.co.uk/e/item?id=1234567890.

Actual behavior

No redirect URL is shown.

uBO version

1.68.0

Browser name and version

Zen (1.17.15b)

Operating System and version

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedissue has been addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions