Skip to content

Commit

Permalink
Merge pull request #10464 from nextcloud/backport/10390/stable4.1
Browse files Browse the repository at this point in the history
[stable4.1] fix(contactsintegration): Limit number of matches
  • Loading branch information
ChristophWurst authored Dec 9, 2024
2 parents 61c8f7d + 2565925 commit 5d4c17e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/Service/ContactsIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ public function getMatchingRecipient(string $userId, string $term): array {
$shareeEnumerationFullMatchUserId = $shareeEnumerationFullMatch && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_userid', 'yes') === 'yes';
$shareeEnumerationFullMatchEmail = $shareeEnumerationFullMatch && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_email', 'yes') === 'yes';

$result = $this->contactsManager->search($term, ['UID', 'FN', 'EMAIL'], ['enumeration' => $shareeEnumeration, 'fullmatch' => $shareeEnumerationFullMatch]);
$result = $this->contactsManager->search(
$term,
['UID', 'FN', 'EMAIL'],
[
'enumeration' => $shareeEnumeration,
'fullmatch' => $shareeEnumerationFullMatch,
'limit' => 20,
],
);
if (empty($result)) {
return [];
}
Expand Down
11 changes: 10 additions & 1 deletion tests/Unit/Service/ContactsIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
Expand Down Expand Up @@ -353,7 +355,14 @@ public function common($term, $searchResult, $allowSystemUsers, $allowSystemUser
->will($this->returnValue(true));
$this->contactsManager->expects($this->once())
->method('search')
->with($term, ['UID', 'FN', 'EMAIL'], ['enumeration' => $allowSystemUsers, 'fullmatch' => $shareeEnumerationFullMatch])
->with(
$term,
['UID', 'FN', 'EMAIL'],
[
'enumeration' => $allowSystemUsers,
'fullmatch' => $shareeEnumerationFullMatch,
'limit' => 20,
])
->will($this->returnValue($searchResult));
}

Expand Down

0 comments on commit 5d4c17e

Please sign in to comment.