Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Limit more contact searches
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Dec 13, 2021
commit 749935e91bdc74c7bf0f78107eecf754c831a200
7 changes: 6 additions & 1 deletion apps/federatedfilesharing/lib/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ protected function getDisplayNameFromContact($federatedCloudId) {
}
}

$addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
$addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookEntries as $entry) {
if (isset($entry['CLOUD'])) {
foreach ($entry['CLOUD'] as $cloudID) {
Expand Down
7 changes: 6 additions & 1 deletion apps/files/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,12 @@ protected function getDisplayNameFromAddressBook(string $search): string {
return $this->displayNames[$search];
}

$addressBookContacts = $this->contactsManager->search($search, ['CLOUD']);
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
Expand Down
7 changes: 6 additions & 1 deletion apps/files_sharing/lib/Activity/Providers/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ protected function getDisplayNameFromAddressBook(string $search): string {
return $this->displayNames[$search];
}

$addressBookContacts = $this->contactsManager->search($search, ['CLOUD']);
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
Expand Down
8 changes: 6 additions & 2 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,12 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
* @return string
*/
private function getDisplayNameFromAddressBook(string $query, string $property): string {
// FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered
$result = \OC::$server->getContactsManager()->search($query, [$property]);
// FIXME: If we inject the contacts manager it gets initialized before any address books are registered
$result = \OC::$server->getContactsManager()->search($query, [$property], [
'limit' => 1,
'enumeration' => false,
'strict_search' => true,
]);
foreach ($result as $r) {
foreach ($r[$property] as $value) {
if ($value === $query && $r['FN']) {
Expand Down
12 changes: 10 additions & 2 deletions apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,11 @@ public function testFormatShare(array $expects, \OCP\Share\IShare $share, array

$cm->method('search')
->willReturnMap([
['[email protected]', ['CLOUD'], [],
['[email protected]', ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'strict_search' => true,
],
[
[
'CLOUD' => [
Expand All @@ -4237,7 +4241,11 @@ public function testFormatShare(array $expects, \OCP\Share\IShare $share, array
],
],
],
['[email protected]', ['EMAIL'], [],
['[email protected]', ['EMAIL'], [
'limit' => 1,
'enumeration' => false,
'strict_search' => true,
],
[
[
'EMAIL' => [
Expand Down
7 changes: 6 additions & 1 deletion apps/sharebymail/lib/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ protected function generateUserParameter($uid) {
* @return string
*/
protected function getContactName($email) {
$addressBookContacts = $this->contactsManager->search($email, ['EMAIL']);
$addressBookContacts = $this->contactsManager->search($email, ['EMAIL'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);

foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
Expand Down
7 changes: 6 additions & 1 deletion lib/private/Collaboration/Collaborators/RemotePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$resultType = new SearchResultType('remotes');

// Search in contacts
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], ['limit' => $limit, 'offset' => $offset]);
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], [
'limit' => $limit,
'offset' => $offset,
'enumeration' => false,
'fullmatch' => false,
]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
Expand Down
5 changes: 4 additions & 1 deletion lib/private/Contacts/ContactsMenu/ContactsStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ public function __construct(IManager $contactsManager,
* @return IEntry[]
*/
public function getContacts(IUser $user, $filter, ?int $limit = null, ?int $offset = null) {
$options = [];
$options = [
'enumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes',
'fullmatch' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes',
];
if ($limit !== null) {
$options['limit'] = $limit;
}
Expand Down
7 changes: 6 additions & 1 deletion lib/private/Federation/CloudIdManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public function resolveCloudId(string $cloudId): ICloudId {
}

protected function getDisplayNameFromContact(string $cloudId): ?string {
$addressBookEntries = $this->contactsManager->search($cloudId, ['CLOUD']);
$addressBookEntries = $this->contactsManager->search($cloudId, ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookEntries as $entry) {
if (isset($entry['CLOUD'])) {
foreach ($entry['CLOUD'] as $cloudID) {
Expand Down
7 changes: 6 additions & 1 deletion lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,12 @@ public static function getItems($itemType, $item = null, $shareType = null, $sha
$row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName();
} elseif (isset($row['share_with']) && $row['share_with'] != '' &&
$row['share_type'] === IShare::TYPE_REMOTE) {
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookEntries as $entry) {
foreach ($entry['CLOUD'] as $cloudID) {
if ($cloudID === $row['share_with']) {
Expand Down