Skip to content

Commit

Permalink
fix(AppAPIService): encode query parameter array via http_build_query
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 committed Oct 18, 2024
1 parent 76cba04 commit 2dc3986
Showing 1 changed file with 2 additions and 15 deletions.
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

0 comments on commit 2dc3986

Please sign in to comment.