diff options
-rw-r--r-- | apps/dav/lib/CardDAV/AddressBookImpl.php | 1 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 6 | ||||
-rw-r--r-- | lib/private/Collaboration/Collaborators/MailPlugin.php | 10 | ||||
-rw-r--r-- | lib/private/ContactsManager.php | 1 | ||||
-rw-r--r-- | lib/public/Contacts/IManager.php | 1 | ||||
-rw-r--r-- | lib/public/IAddressBook.php | 1 |
6 files changed, 18 insertions, 2 deletions
diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php index 8b0d494fd01..1b74f329f1f 100644 --- a/apps/dav/lib/CardDAV/AddressBookImpl.php +++ b/apps/dav/lib/CardDAV/AddressBookImpl.php @@ -107,6 +107,7 @@ class AddressBookImpl implements IAddressBook { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped * - 'limit' - Set a numeric limit for the search results * - 'offset' - Set the offset for the limited search results + * - 'wildcard' - Whether the search should use wildcards * @return array an array of contacts which are arrays of key-value-pairs * example result: * [ diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 13926ef12ce..403c4646e47 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -1024,6 +1024,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are * - 'limit' - Set a numeric limit for the search results * - 'offset' - Set the offset for the limited search results + * - 'wildcard' - Whether the search should use wildcards * @return array an array of contacts which are arrays of key-value-pairs */ public function search($addressBookId, $pattern, $searchProperties, $options = []): array { @@ -1062,6 +1063,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { array $searchProperties, array $options = []): array { $escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false; + $useWildcards = !\array_key_exists('wildcard', $options) || $options['wildcard'] !== false; $query2 = $this->db->getQueryBuilder(); @@ -1103,7 +1105,9 @@ class CardDavBackend implements BackendInterface, SyncSupport { // No need for like when the pattern is empty if ('' !== $pattern) { - if (!$escapePattern) { + if (!$useWildcards) { + $query2->andWhere($query2->expr()->eq('cp.value', $query2->createNamedParameter($pattern))); + } elseif (!$escapePattern) { $query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern))); } else { $query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 7245501a8bf..59861247ced 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -101,7 +101,15 @@ class MailPlugin implements ISearchPlugin { $emailType = new SearchResultType('emails'); // Search in contacts - $addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN'], ['limit' => $limit, 'offset' => $offset]); + $addressBookContacts = $this->contactsManager->search( + $search, + ['EMAIL', 'FN'], + [ + 'limit' => $limit, + 'offset' => $offset, + 'wildcard' => $this->shareeEnumeration, + ] + ); $lowerSearch = strtolower($search); foreach ($addressBookContacts as $contact) { if (isset($contact['EMAIL'])) { diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php index e702a439153..7bdb8293857 100644 --- a/lib/private/ContactsManager.php +++ b/lib/private/ContactsManager.php @@ -42,6 +42,7 @@ class ContactsManager implements IManager { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped * - 'limit' - Set a numeric limit for the search results * - 'offset' - Set the offset for the limited search results + * - 'wildcard' - Whether the search should use wildcards * @return array an array of contacts which are arrays of key-value-pairs */ public function search($pattern, $searchProperties = [], $options = []) { diff --git a/lib/public/Contacts/IManager.php b/lib/public/Contacts/IManager.php index 8d24249e997..6bf569e9bbd 100644 --- a/lib/public/Contacts/IManager.php +++ b/lib/public/Contacts/IManager.php @@ -93,6 +93,7 @@ interface IManager { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped * - 'limit' - Set a numeric limit for the search results * - 'offset' - Set the offset for the limited search results + * - 'wildcard' - Whether the search should use wildcards * @return array an array of contacts which are arrays of key-value-pairs * @since 6.0.0 */ diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index b0196764be3..738745376d3 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -67,6 +67,7 @@ namespace OCP { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped * - 'limit' - Set a numeric limit for the search results * - 'offset' - Set the offset for the limited search results + * - 'wildcard' - Whether the search should use wildcards * @return array an array of contacts which are arrays of key-value-pairs * example result: * [ |