aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-05-15 09:47:22 +0200
committerJoas Schilling <coding@schilljs.com>2024-05-15 09:48:23 +0200
commit2bd54d30e5eb6465d789f9261b1b8c5e8fe9e57a (patch)
tree83d77b2298288addce888fa7d39449b6ee9799f1 /core
parent2b2a866b05a371e0a15d83bfc54bebc33e74f2c5 (diff)
downloadnextcloud-server-2bd54d30e5eb6465d789f9261b1b8c5e8fe9e57a.tar.gz
nextcloud-server-2bd54d30e5eb6465d789f9261b1b8c5e8fe9e57a.zip
fix(search): Limit maximum number of search results
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/UnifiedSearchController.php7
-rw-r--r--core/openapi.json2
2 files changed, 6 insertions, 3 deletions
diff --git a/core/Controller/UnifiedSearchController.php b/core/Controller/UnifiedSearchController.php
index 469c6c6ed7b..3df7749ce72 100644
--- a/core/Controller/UnifiedSearchController.php
+++ b/core/Controller/UnifiedSearchController.php
@@ -92,7 +92,7 @@ class UnifiedSearchController extends OCSController {
* @param string $providerId ID of the provider
* @param string $term Term to search
* @param int|null $sortOrder Order of entries
- * @param int|null $limit Maximum amount of entries
+ * @param int|null $limit Maximum amount of entries, limited to 25
* @param int|string|null $cursor Offset for searching
* @param string $from The current user URL
*
@@ -113,6 +113,9 @@ class UnifiedSearchController extends OCSController {
): DataResponse {
[$route, $routeParameters] = $this->getRouteInformation($from);
+ $limit ??= SearchQuery::LIMIT_DEFAULT;
+ $limit = max(1, min($limit, 25));
+
try {
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());
} catch (UnsupportedFilter|InvalidArgumentException $e) {
@@ -125,7 +128,7 @@ class UnifiedSearchController extends OCSController {
new SearchQuery(
$filters,
$sortOrder ?? ISearchQuery::SORT_DATE_DESC,
- $limit ?? SearchQuery::LIMIT_DEFAULT,
+ $limit,
$cursor,
$route,
$routeParameters
diff --git a/core/openapi.json b/core/openapi.json
index 1c7b2caeeac..014e001b08e 100644
--- a/core/openapi.json
+++ b/core/openapi.json
@@ -5366,7 +5366,7 @@
{
"name": "limit",
"in": "query",
- "description": "Maximum amount of entries",
+ "description": "Maximum amount of entries, limited to 25",
"schema": {
"type": "integer",
"format": "int64",