Skip to content

Commit

Permalink
Merge pull request #41486 from nextcloud/fix/41470/invalid_user_group
Browse files Browse the repository at this point in the history
Fix invalid users/groups handling in advanced search
  • Loading branch information
Altahrim authored Nov 16, 2023
2 parents 0d4ece5 + 33837e7 commit ae31d03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion core/Controller/UnifiedSearchController.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit ae31d03

Please sign in to comment.