Merge pull request #45317 from nextcloud/bugfix/noid/limit-maximum-number-of-search-results

fix(search): Limit maximum number of search results
This commit is contained in:
Joas Schilling 2024-05-16 10:10:09 +02:00 committed by GitHub
commit ef1c32a222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -7006,7 +7006,7 @@
{
"name": "limit",
"in": "query",
"description": "Maximum amount of entries",
"description": "Maximum amount of entries, limited to 25",
"schema": {
"type": "integer",
"format": "int64",