w3c / webextensions

Charter and administrivia for the WebExtensions Community Group (WECG)
Other
594 stars 54 forks source link

Inconsistency: Ability to open extension pages using redirect #381

Open lukeselker opened 1 year ago

lukeselker commented 1 year ago

Hi all!

When using Declarative Net Request to handle extension redirects, I'm having an inconsistency between browsers when using a callback url to open the extension. In chrome, this redirect to a chrome-extension://<extension-id> url functions properly, but in safari, the redirect to a safari-web-extension://<extension-id> url is being blocked with the following error:

Redirection to URL with a scheme that is not HTTP(S)

Is there a way for this to be handled consistently across browsers? I understand the reasoning behind only allowing https/http redirects, but it seems that safari-web-extension scheme should also be an allowed scheme for redirects.

sammacbeth commented 1 year ago

For this use-case you have to use extensionPath instead of url in Safari, i.e:

action: {
   type: "redirect",
   redirect: {
    extensionPath: "/image.png",
  }
}

Here's a full example: https://github.com/duckduckgo/mv3-compat-tests/blob/main/Shared%20(Extension)/Resources/tests/test.declarativeNetRequest.js#L274-L278

lukeselker commented 1 year ago

Thanks @sammacbeth, but this doesn't allow us to do regexSubstitution when using a redirect to an extension page.

lukeselker commented 1 year ago

@xeenon let me know if you need me to open a bug in https://bugs.webkit.org/ for this 👍

xeenon commented 1 year ago

@lukeselker Feel free, thanks!

lukeselker commented 1 year ago

Looks like someone just opened a bug today for this exact issue -> https://bugs.webkit.org/show_bug.cgi?id=256054

tophf commented 4 months ago

A possible solution is to allow regex substitutions \0 \1 etc. inside extensionPath when regexFilter is present. There'll be an additional benefit in case #604 is solved: no need to expose the target in web_accessible_resources.