matomo icon indicating copy to clipboard operation
matomo copied to clipboard

[Bug] URL decoding should not be used when saving regular expressions

Open 9joshua opened this issue 10 months ago • 0 comments

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?

  1. Create a Goal with a regex match condition of: foo%20bar
  2. Save the Goal and view the saved version of the regex: foo bar
  3. Track a page like https://example.com?foo%20bar=1
  4. 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

9joshua avatar Apr 23 '24 23:04 9joshua