Skip to content

Commit f15c6ea

Browse files
edward-lybigcat88
andauthored
fix(AppAPIService): encode query parameter arrays via http_build_query (nextcloud#412)
Resolves nextcloud#384. If the checks still pass and this gets merged, perhaps we should take a look at other apps to see if they need to be updated in the same way. Signed-off-by: Edward Ly <[email protected]> Co-authored-by: Alexander Piskun <[email protected]>
1 parent 9061b82 commit f15c6ea

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

lib/Service/AppAPIService.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function prepareRequestToExApp(
181181

182182
if ((!array_key_exists('multipart', $options)) && (count($params)) > 0) {
183183
if ($method === 'GET') {
184-
$url .= '?' . $this->getUriEncodedParams($params);
184+
$url .= '?' . http_build_query($params);
185185
} else {
186186
$options['json'] = $params;
187187
}
@@ -231,7 +231,7 @@ private function prepareRequestToExApp2(
231231

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

261-
private function getUriEncodedParams(array $params): string {
262-
$paramsContent = '';
263-
foreach ($params as $key => $value) {
264-
if (is_array($value)) {
265-
foreach ($value as $oneArrayValue) {
266-
$paramsContent .= $key . '[]=' . urlencode($oneArrayValue) . '&';
267-
}
268-
unset($params[$key]);
269-
}
270-
}
271-
return $paramsContent . http_build_query($params);
272-
}
273-
274261
/**
275262
* AppAPI authentication request validation for Nextcloud:
276263
* - checks if ExApp exists and is enabled

0 commit comments

Comments
 (0)