Trim params wildcard inconsistency
See original GitHub issueThis had me confused for quite a while with parameters being trimmed that I didn’t intend until I added debug logging manually to see what was going on. Basically when a filter rule’s Trim URL Parameters
value contains more than 1 asterisk, the first asterisk is replaced by the regex pattern .*
but all the others are left alone.
Personally I’d prefer to just work with regex, but I understand the asterisk replacement is there so users don’t have to know regex and to be somewhat consistent with the pattern matching for hosts/paths. It’s a bit awkward that it’s actually a regex except for the asterisk because it means you can’t use an asterisk in any regex context other than .*
(unless you abuse this bug and know that only the first asterisk works like that).
The obvious fix is to replace .replace("*", ".*")
with .replace(/\*/g, ".*")
so all asterisks are replaced, not just the first. A more complete solution might allow the user to deliberately indicate a particular parameter is a regex (eg /to_be_trim*ed/
) whilst properly treating all others as literal strings, but that seems like a lot of work to get right and performant!
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
I added regexp escaping and fixed the logic bug 👍
beta version for testing: https://addons.mozilla.org/addon/requestcontrol/versions/1.7.0beta2
Argh… onInstalled API documentation didn’t mention anything that the “previousVersion” property is available starting from version 55 of Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1313648
I added a fallback for it and I’ve now disabled 1.7.0 in AMO.
If you didn’t do any changes to the rules, you should be able to migrate them installing 1.7.1beta3