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

fix(AppAPIService): encode query parameter array via http_build_query [backport/stable30] #422

Open
wants to merge 2 commits into
base: stable30
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions lib/Service/AppAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function prepareRequestToExApp(

if ((!array_key_exists('multipart', $options)) && (count($params)) > 0) {
if ($method === 'GET') {
$url .= '?' . $this->getUriEncodedParams($params);
$url .= '?' . http_build_query($params);
} else {
$options['json'] = $params;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ private function prepareRequestToExApp2(

if ((!array_key_exists('multipart', $options))) {
if (count($queryParams) > 0) {
$url .= '?' . $this->getUriEncodedParams($queryParams);
$url .= '?' . http_build_query($queryParams);
}
if ($method !== 'GET' && count($bodyParams) > 0) {
$options['json'] = $bodyParams;
Expand All @@ -258,19 +258,6 @@ private function swapAuthorizationHeader(array $headers): array {
return $headers;
}

private function getUriEncodedParams(array $params): string {
$paramsContent = '';
foreach ($params as $key => $value) {
if (is_array($value)) {
foreach ($value as $oneArrayValue) {
$paramsContent .= $key . '[]=' . urlencode($oneArrayValue) . '&';
}
unset($params[$key]);
}
}
return $paramsContent . http_build_query($params);
}

/**
* AppAPI authentication request validation for Nextcloud:
* - checks if ExApp exists and is enabled
Expand Down
Loading