matomo
matomo copied to clipboard
[Bug] URL decoding should not be used when saving regular expressions
What happened?
When creating a regex condition for a matching URL to trigger a Goal, the space character cannot be defined correctly.
For example, say I want to match any of these terms: "to-schools" "institutions" "youth programmes"
This should work regardless of whether URL decoding is used by Matomo when assessing the URL or not:
.*(to-schools|institutions|youth%20programmes|youth programmes)(.*|$)
It however does not work because URL decoding is applied to the expression when the Goal settings are saved. So the above regex is stored like this:
.*(to-schools|institutions|youth programmes|youth programmes)(.*|$)
Matomo does not URL decode the URL when it is evaluated, so the %20
is present in the URL being evaluated and therefore does not match the regex.
The only work around appears to be to add three wildcard characters so Matomo will find a match for %20
...
.*(to-schools|institutions|youth.{3}programmes)(.*|$)
What should happen?
Matomo should not URL decode regex expressions when they are saved.
How can this be reproduced?
- Create a Goal with a regex match condition of:
foo%20bar
- Save the Goal and view the saved version of the regex:
foo bar
- Track a page like https://example.com?foo%20bar=1
- The Goal will not be triggered
Matomo version
5.0.3
PHP version
8.1
Server operating system
Linux
What browsers are you seeing the problem on?
Chrome
Computer operating system
Ubuntu
Relevant log output
No response
Validations
- [X] Read our Contributing Guidelines.
- [X] Follow our Security Policy.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating duplicates.
- [X] The provided steps to reproduce is a minimal reproducible of the Bug.