-
Notifications
You must be signed in to change notification settings - Fork 56
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
Proposal: Decode regexFilter
matches in Declarative Net Request as query parameters
#636
Comments
Thanks for the proposal! This is a solution to the problem in #302.
Also, for some future-proofing, we should have "redirect": {
"regexSubstitution": "\\1",
"decodeRegexMatches": ["decodeURIComponent"]
} This looks good to me otherwise. |
This would process each captured group referenced by |
No strong feelings on this, I think that's a reasonable justification.
I also don't feel strongly here. If we don't do it to begin with, I think we could quite easily add that later without causing too many issues.
Right, so |
It might make sense to indicate the specific captured groups that need to be decoded e.g. P.S. Suggesting to replace |
Thanks for the thoughts @tophf!
I briefly mention this under "Limitations". I'm supportive of the ability to do that, but I think we might want to leave it out for the MVP. Otherwise it opens other questions (can you apply different decodings to different matches etc.) and I think this quickly becomes a larger proposal. Updated the description and added an existing DNR label. |
This should be part of To enable future extensions, I would recommend a syntax that allows specifying separate substitutions for each individual match. The bare minimum is to support this through numbered capturing groups ( Here is an example that can be extended in the future. I'm suggesting an array syntax here instead of a dictionary in case (future) operations want to be dependent on the result of previous transformations.
|
@Rob--W, I spoke to the Chrome team about your updated syntax. We're a little hesitant due to the additional verbosity, but can also see the benefit, so we'd be comfortable with this. |
As mentioned in #302, many sites add an additional redirect to external links. These interstitials often include the destination URL as a query parameter with URI component encoding:
Examples
https://www.google.com/url?q=https%3A%2F%2Fexample.com%2F%3Ftest
https://l.facebook.com/l.php?u=https%3A%2F%2Fexample.com%2F%3Ftest
https://steamcommunity.com/linkfilter/?u=https%3A%2F%2Fexample.com%2F%3Ftest
https://forum.donanimhaber.com/externallinkredirect?url=https%3A%2F%2Fexample.com%2F%3Ftest
Current Situation
A simple browser.declarativeNetRequest rule to skip these redirects would be as follows:
However, this does not decode the query parameter and therefore fails to properly redirect. For example, visiting
https://steamcommunity.com/linkfilter/?u=https://example.com?test%26hello
does not properly decode the %26 in the destination URL.Proposal
Add a
decodeRegexMatches
property in the Redirect or RuleCondition dictionaries. This would process each match through decodeURIComponent before performing theregexSubstitution
.Limitations
This does not address all possible types of encoding. However, I wasn't able to find many exceptions - only one in fact - and this covers the sites which extensions like Privacy Badger were handling in Manifest V2.
Ideally we would have a more complete API, supporting things like only decoding certain matches or applying different types of processing, perhaps in a given order. However, this proposal was written with the hope of keeping the implementation complexity down so this can move forward sooner.
The text was updated successfully, but these errors were encountered: