Opened on 02/16/2019 at 01:26:58 PM
Closed on 02/21/2019 at 12:47:38 PM
Last modified on 07/25/2019 at 02:14:30 PM
#7294 closed change (fixed)
Implement strip-fetch-query-parameter snippet
Reported by: | mjethani | Assignee: | agiammarchi |
---|---|---|---|
Priority: | P2 | Milestone: | |
Module: | Core | Keywords: | circumvention |
Cc: | sebastian | Blocked By: | |
Blocking: | Platform: | Unknown / Cross platform | |
Ready: | yes | Confidential: | no |
Tester: | Ross | Verified working: | yes |
Review URL(s): |
https://gitlab.com/eyeo/adblockplus/adblockpluscore/merge_requests/23 |
Description (last modified by mjethani)
Background
In some cases we need to strip parameters from the query string of a URL while letting the request through. This is not always possible using the $rewrite option, especially with preflight OPTIONS requests, because doing so invalidates the request (307 Temporary Redirect). A snippet that wraps fetch() to strip out the given query string parameter would be handy.
What to change
Implement a snippet called strip-fetch-query-parameter with the following signature:
function stripFetchQueryParameter(name, urlPattern = null)
name should be the unencoded name of the parameter. For example, in the query string ?first%20name=John, the parameter name is first name (space).
The optional urlPattern can be a literal string or a pattern (regular expression surrounded by /) that the URL must match. If null, the snippet should work for any URL.
Hints for testers
Try the following document:
<!DOCTYPE html> <html> <body> <script> setTimeout(() => { fetch("https://example.com/?foo=1&bar=2"); }, 500); </script> </body> </html>
The filter #$#strip-fetch-query-parameter foo example should cause the request to go to https://example.com/?bar=2 (foo is dropped). The filter #$#strip-fetch-query-parameter foo too should do the same.
The filter #$#strip-fetch-query-parameter bar other should cause the request to go to https://example.com/?foo=1&bar=2 (bar is not dropped).
Attachments (0)
Change History (15)
comment:1 Changed on 02/21/2019 at 07:34:54 AM by abpbot
comment:2 Changed on 02/21/2019 at 07:38:10 AM by mjethani
- Owner set to agiammarchi
comment:6 Changed on 02/21/2019 at 08:16:13 AM by mjethani
- Status changed from new to reviewing
comment:7 Changed on 02/21/2019 at 12:46:24 PM by abpbot
A commit referencing this issue has landed:
Issue 7294 - Pass necessary functions to strip-fetch-query-parameter
comment:8 Changed on 02/21/2019 at 12:47:38 PM by mjethani
- Resolution set to fixed
- Status changed from reviewing to closed
comment:9 Changed on 03/20/2019 at 04:56:31 PM by abpbot
Some commits referencing this issue have landed:
comment:10 Changed on 03/26/2019 at 04:33:22 PM by Ross
- Tester changed from Unknown to Ross
- Verified working set
comment:11 Changed on 03/26/2019 at 04:57:57 PM by agiammarchi
Most likely 'cause they don't have fetch to start with, so that the page would throw errors regardless ?
comment:12 Changed on 03/26/2019 at 11:05:38 PM by sebastian
- Cc sebastian added
According to MDN, all these browsers support the fetch() API.
comment:13 Changed on 03/27/2019 at 09:08:08 AM by agiammarchi
I think Manish found the issue with the URL searchParams
comment:14 Changed on 04/04/2019 at 09:42:49 AM by mjethani
- Sensitive unset
comment:15 Changed on 07/25/2019 at 02:14:30 PM by Ross
Done. Working as described. Now works in Chrome 49/Edge/Firefox Mobile.
ABP 0.9.15.2340
Microsoft Edge 44.17763.1.0 / Windows 10 1809
ABP 3.5.2.2340
Chrome 49.0.2623.75 / Windows 10 1809
Chrome 75.0.3770.142 / Windows 10 1809
Opera 36.0.2130.65 / Windows 10 1809
Opera 62.0.3331.72 / Windows 10 1809
Firefox 51.0 / Windows 10 1809
Firefox 68.0 / Windows 10 1809
Firefox Mobile 68.0 / Android 7.2.2
A commit referencing this issue has landed:
Issue 7294 - Implement strip-fetch-query-parameter snippet