]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only limit search in the system address book
authorJoas Schilling <coding@schilljs.com>
Wed, 8 Dec 2021 15:59:32 +0000 (16:59 +0100)
committerJoas Schilling <coding@schilljs.com>
Mon, 13 Dec 2021 12:48:47 +0000 (13:48 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Collaboration/Collaborators/MailPlugin.php
lib/private/ContactsManager.php
lib/public/Contacts/IManager.php

index 59861247ced6d8676db30c6ddfac247fcb982a94..7c245c4f9c42b1e127b52a7f4f6fae8b04ca3e5d 100644 (file)
@@ -107,7 +107,8 @@ class MailPlugin implements ISearchPlugin {
                        [
                                'limit' => $limit,
                                'offset' => $offset,
-                               'wildcard' => $this->shareeEnumeration,
+                               'enumeration' => $this->shareeEnumeration,
+                               'fullmatch' => $this->shareeEnumerationFullMatch,
                        ]
                );
                $lowerSearch = strtolower($search);
index 7bdb8293857e6757e003dae7ea97d7a1302e4aa7..557cf98c66b4024bd14494a9d8f6b9ea51c7d04c 100644 (file)
@@ -42,14 +42,26 @@ 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
+        *      - 'enumeration' - Whether user enumeration on system address book is allowed
+        *      - 'fullmatch' - Whether matching on full detail in system address book is allowed
         * @return array an array of contacts which are arrays of key-value-pairs
         */
        public function search($pattern, $searchProperties = [], $options = []) {
                $this->loadAddressBooks();
                $result = [];
                foreach ($this->addressBooks as $addressBook) {
-                       $r = $addressBook->search($pattern, $searchProperties, $options);
+                       $searchOptions = $options;
+
+                       if ($addressBook->isSystemAddressBook()) {
+                               $fullMatch = !\array_key_exists('fullmatch', $options) || $options['fullmatch'] !== false;
+                               if (!$fullMatch) {
+                                       // Neither full match is allowed, so skip the system address book
+                                       continue;
+                               }
+                               $searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false;
+                       }
+
+                       $r = $addressBook->search($pattern, $searchProperties, $searchOptions);
                        $contacts = [];
                        foreach ($r as $c) {
                                $c['addressbook-key'] = $addressBook->getKey();
index 6bf569e9bbd4dc40430e827a579df197697f6aac..6d5f318cfa8d1cebac7f5267d59fe7e84bdf39a5 100644 (file)
@@ -93,7 +93,8 @@ 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
+        *      - 'enumeration' - Whether user enumeration on system address book is allowed
+        *      - 'fullmatch' - Whether matching on full detail in system addresss book is allowed
         * @return array an array of contacts which are arrays of key-value-pairs
         * @since 6.0.0
         */