Merge pull request #41486 from nextcloud/fix/41470/invalid_user_group

Fix invalid users/groups handling in advanced search
This commit is contained in:
Benjamin Gaussorgues 2023-11-16 02:50:09 +01:00 committed by GitHub
commit ae31d03217
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -28,6 +28,7 @@ declare(strict_types=1);
*/
namespace OC\Core\Controller;
use InvalidArgumentException;
use OC\Search\SearchComposer;
use OC\Search\SearchQuery;
use OCA\Core\ResponseDefinitions;
@ -111,7 +112,7 @@ class UnifiedSearchController extends OCSController {
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(

View file

@ -38,10 +38,11 @@ class GroupFilter implements IFilter {
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 {

View file

@ -38,10 +38,11 @@ class UserFilter implements IFilter {
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 {