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

make sure > can be used in segments when using bulk requests #9497

Merged
merged 1 commit into from Jan 20, 2016
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Jan 11, 2016

fixes #9393

In #9393 (comment) I thought about fixing it in API/Request and even initially implemented it this way but after a lot of thinking it should be rather fixed in getBulkRequest as the problem is actually specific to bulk requests. There is already this unsanitize https://github.com/piwik/piwik/blob/2.16.0-b1/plugins/API/API.php#L483 which is undone by Request. So we should also fix it in getBulkRequest again where the initial unsanitize was done.

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 11, 2016
@tsteur tsteur added this to the 2.16.0 milestone Jan 11, 2016
if (!empty($params['segment']) && strpos($url, 'segment=') > -1) {
// only unsanitize input when segment is actually present in URL, not when it was used from
// $defaultRequest in Request::getRequestArrayFromString from $_GET/$_POST
$params['segment'] = urlencode(Common::unsanitizeInputValue($params['segment']));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The urlencode is not really needed I believe but added it for now. Otherwise we pass eg actions>5 (instead of actions%3E5) to the API methods. This shouldn't be a problem as all output should be proper encoded anyway. I did it because a comment here https://github.com/piwik/piwik/blob/2.15.1-b10/core/API/Request.php#L484 says we want URL encoded segments. I know Piwik\Segment can handle both urlencoded and urldecoded so it might be good to remove the urlencode here as it might be a problem if the segment parameter in the bulk request URL was encoded twice already.

mattab pushed a commit that referenced this pull request Jan 20, 2016
make sure > can be used in segments when using bulk requests
@mattab mattab merged commit 5b9e1e9 into master Jan 20, 2016
@mattab
Copy link
Member

mattab commented Jan 20, 2016

Quite a tricky bug fix, well done @tsteur

@mattab mattab deleted the 9393 branch January 20, 2016 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants