Skip to content

Convert multidimensional query parameter args in URLs correctly #211

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

Merged
merged 6 commits into from
May 24, 2018

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Apr 25, 2018

PHP supports sending/parsing multidimensional arrays in the URL, eg:

param[key1][key2][] = 12

which would be parsed as:

[
    'key1' => [
        'key2' => [
            12,
        ],
    ],
]

Python does not, so if you're replaying logs for a plugin that uses multidimensional array tracker query parameters, the replay will fail.

This fixes the issue by converting such parameters manually. Tried also to convert the parsed query string back into a query string (which would have been far simpler), but python 2 has trouble with converting querystrings with unicode.

Note: I tried converting the string parts to unicode before calling urllib.urlencode() (as suggested here: https://stackoverflow.com/questions/6480723/urllib-urlencode-doesnt-like-unicode-values-how-about-this-workaround), but that results in odd test failures in ImportLogsTest.php. This change doesn't.

Core build for this PR is here: https://travis-ci.org/matomo-org/matomo/builds/372841147

@diosmosis diosmosis added this to the Current sprint milestone Apr 26, 2018
@diosmosis diosmosis force-pushed the array-args branch 4 times, most recently from 590c208 to 7d5a865 Compare April 29, 2018 23:51
@diosmosis diosmosis merged commit 749dfd4 into master May 24, 2018
@diosmosis diosmosis deleted the array-args branch May 24, 2018 22:36
@innocraft-automation innocraft-automation removed this from the Current sprint milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants