Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid users/groups handling in advanced search #41486

Merged
merged 1 commit into from Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/Controller/UnifiedSearchController.php
Expand Up @@ -28,6 +28,7 @@
*/
namespace OC\Core\Controller;

use InvalidArgumentException;
use OC\Search\SearchComposer;
use OC\Search\SearchQuery;
use OCA\Core\ResponseDefinitions;
Expand Down Expand Up @@ -111,7 +112,7 @@ public function search(

try {
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());
} catch (UnsupportedFilter $e) {
} catch (UnsupportedFilter|InvalidArgumentException $e) {
return new DataResponse($e->getMessage(), Http::STATUS_BAD_REQUEST);
}
return new DataResponse(
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Search/Filter/GroupFilter.php
Expand Up @@ -38,10 +38,11 @@ public function __construct(
string $value,
IGroupManager $groupManager,
) {
$this->group = $groupManager->get($value);
if ($this->group === null) {
$group = $groupManager->get($value);
if ($group === null) {
throw new InvalidArgumentException('Group '.$value.' not found');
}
$this->group = $group;
}

public function get(): IGroup {
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Search/Filter/UserFilter.php
Expand Up @@ -38,10 +38,11 @@ public function __construct(
string $value,
IUserManager $userManager,
) {
$this->user = $userManager->get($value);
if ($this->user === null) {
$user = $userManager->get($value);
if ($user === null) {
throw new InvalidArgumentException('User '.$value.' not found');
}
$this->user = $user;
}

public function get(): IUser {
Expand Down