From 2b3079765c681f38e08a34aeef087220a9262e5c Mon Sep 17 00:00:00 2001 From: Edward Ly Date: Mon, 7 Oct 2024 00:37:58 -0700 Subject: [PATCH] fix(AppAPIService): encode query parameter arrays via http_build_query Signed-off-by: Edward Ly --- lib/Service/AppAPIService.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/Service/AppAPIService.php b/lib/Service/AppAPIService.php index cc391b36..e006d62e 100644 --- a/lib/Service/AppAPIService.php +++ b/lib/Service/AppAPIService.php @@ -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; } @@ -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; @@ -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