Skip to content
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

Unsanitize custom dimension values #22609

Open
wants to merge 2 commits into
base: 5.x-dev
Choose a base branch
from

Conversation

MichaelRoosz
Copy link
Contributor

@MichaelRoosz MichaelRoosz commented Sep 21, 2024

Description:

When migrating from custom variables to dimensions, we noticed that characters like a double quote (") are escaped when saved to the database.

For example:
_paq.push(['setCustomVariable', 1, 'name1234', 'test"1234', 'visit']);
will write test"1234 to the database

but
_paq.push(['setCustomDimension', 1, 'test"1234']);
will write test"1234 to the database.

Since the values are limited to 200 characters, this seems quite wasteful.

The reason for the difference is:

Custom variables values are unsanitized:
https://github.com/matomo-org/plugin-CustomVariables/blob/40c61ad3f2161eec0f3a930613f58384b82af02c/Tracker/CustomVariablesRequestProcessor.php#L101

Custom dimension values coming from an extraction are unsanitized, too:

$value = $extraction->extract($request);

$dimension = Common::unsanitizeInputValue($dimension);

So it seems logical that "normal" dimension values should also be unsanitized.

Review

Copy link
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Oct 18, 2024
@MichaelRoosz
Copy link
Contributor Author

Anything I can add or improve to get this merged?

@michalkleiner
Copy link
Contributor

Thanks for the follow up @MichaelRoosz. Since no test started failing, it seems we don't have this specific use case covered. Would you be able to have a look where the processor is being tested and add a test for this scenario?

@github-actions github-actions bot removed the Stale The label used by the Close Stale Issues action label Oct 22, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale The label used by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants