-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix: do not partial match url params extraction #22281
base: 5.x-dev
Are you sure you want to change the base?
fix: do not partial match url params extraction #22281
Conversation
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
Tests unrelated to my changes are failing |
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
This PR was last updated more than one month ago, maybe it's time to close it. Please check if there is anything we still can do or close this PR. ping @matomo-org/core-reviewers |
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
Description:
Fix for #16137.
Custom Action Dimensions have an option to automatically extract values from the URL Search Parameters. As mentioned in the docs, it does not allow using Regex because it's supposed to be a "simple" match. One would assume it's doing a simple check to fetch the exact match for the URL parameter.
However, it's actually constructing a partial match with the regex
\?.*pattern=([^&]*)
. This works fine in most cases, but if thepattern
is included in another pattern's word ending, this regex picks that up instead.So imagine trying to extract the
type
parameter from the URLIt should match
type=foo
and returnsfoo
in theory, but current regex actually matchestype=baz
at the end fromcontenttype=baz
because the regex is only searching for a parameter that ends with the specified pattern, in this casetype
. To fix this, we know that valid URLs don't have?
or&
unless they are for search params (as they should be URL encoded otherwise), we can construct the regex[?&]pattern=([^&]*)
instead to make sure the exact pattern is matched in the URL.Review