Compare commits

...

2 Commits

Author SHA1 Message Date
Robin Appelman a9c9db583e
extend debug check for non utf8 search results
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-09 14:08:51 +02:00
Robin Appelman a39293aa75
add debug check for non utf8 search results
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-09 13:49:22 +02:00
1 changed files with 12 additions and 0 deletions

View File

@ -48,8 +48,20 @@ class SearchController extends Controller {
* @NoAdminRequired
*/
public function search(string $query, array $inApps = [], int $page = 1, int $size = 30): JSONResponse {
/** @var \OCP\Search\Result[] $results */
$results = $this->searcher->searchPaged($query, $inApps, $page, $size);
foreach ($results as $result) {
if (!mb_check_encoding($result->name, 'utf8') || !mb_check_encoding($result->link, 'utf8')) {
throw new \Exception("Search result contains non utf8 data: " . $result->name);
}
$response = json_encode($result);
if ($response === false) {
throw new \Exception("Search result contains non utf8 data: " . $result->name);
}
}
return new JSONResponse($results);
}
}