Browse Source

fix(search): Limit maximum number of search results

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v28.0.6rc1
Joas Schilling 1 month ago
parent
commit
901be699e4
No account linked to committer's email address
2 changed files with 6 additions and 3 deletions
  1. 5
    2
      core/Controller/UnifiedSearchController.php
  2. 1
    1
      core/openapi.json

+ 5
- 2
core/Controller/UnifiedSearchController.php View File

@@ -90,7 +90,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
*
@@ -110,6 +110,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) {
@@ -122,7 +125,7 @@ class UnifiedSearchController extends OCSController {
new SearchQuery(
$filters,
$sortOrder ?? ISearchQuery::SORT_DATE_DESC,
$limit ?? SearchQuery::LIMIT_DEFAULT,
$limit,
$cursor,
$route,
$routeParameters

+ 1
- 1
core/openapi.json View File

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

Loading…
Cancel
Save