diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-05-16 10:10:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 10:10:09 +0200 |
commit | ef1c32a222c2f0fb490337f81680e88e8d0f85de (patch) | |
tree | 9f4c85cbf68dd5072f8370c17cb222917ee0571c /core/Controller | |
parent | bd6989d365b465857e8a6b722dcbc77c520f3f9d (diff) | |
parent | 2bd54d30e5eb6465d789f9261b1b8c5e8fe9e57a (diff) | |
download | nextcloud-server-ef1c32a222c2f0fb490337f81680e88e8d0f85de.tar.gz nextcloud-server-ef1c32a222c2f0fb490337f81680e88e8d0f85de.zip |
Merge pull request #45317 from nextcloud/bugfix/noid/limit-maximum-number-of-search-results
fix(search): Limit maximum number of search results
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/UnifiedSearchController.php | 7 |
1 files changed, 5 insertions, 2 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 |