summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-07-03 09:09:03 +0200
committerGitHub <noreply@github.com>2020-07-03 09:09:03 +0200
commitffc85ad61420acb1b66646b57f035f8c461c64ac (patch)
tree9e98881a906c629e5ecff8c98abe4a0b003af39c /core
parent0825530a1b1cbb98195ec15cbbd46d121bc65373 (diff)
parentfda55db4c97df9e8973645ed3164457a426a5a23 (diff)
downloadnextcloud-server-ffc85ad61420acb1b66646b57f035f8c461c64ac.tar.gz
nextcloud-server-ffc85ad61420acb1b66646b57f035f8c461c64ac.zip
Merge pull request #21431 from nextcloud/search-filter-invalid-results
Filter out search results that have invalid encoding
Diffstat (limited to 'core')
-rw-r--r--core/Controller/SearchController.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/Controller/SearchController.php b/core/Controller/SearchController.php
index 8d3a6f623b7..a24aa7fa1ec 100644
--- a/core/Controller/SearchController.php
+++ b/core/Controller/SearchController.php
@@ -28,20 +28,28 @@ namespace OC\Core\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\ILogger;
use OCP\IRequest;
use OCP\ISearch;
+use OCP\Search\Result;
class SearchController extends Controller {
/** @var ISearch */
private $searcher;
+ /** @var ILogger */
+ private $logger;
- public function __construct(string $appName,
- IRequest $request,
- ISearch $search) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ ISearch $search,
+ ILogger $logger
+ ) {
parent::__construct($appName, $request);
$this->searcher = $search;
+ $this->logger = $logger;
}
/**
@@ -50,6 +58,15 @@ class SearchController extends Controller {
public function search(string $query, array $inApps = [], int $page = 1, int $size = 30): JSONResponse {
$results = $this->searcher->searchPaged($query, $inApps, $page, $size);
+ $results = array_filter($results, function (Result $result) {
+ if (json_encode($result, JSON_HEX_TAG) === false) {
+ $this->logger->warning("Skipping search result due to invalid encoding: {type: " . $result->type . ", id: " . $result->id . "}");
+ return false;
+ } else {
+ return true;
+ }
+ });
+
return new JSONResponse($results);
}
}