diff options
author | Louis <6653109+artonge@users.noreply.github.com> | 2022-05-05 17:52:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 17:52:13 +0200 |
commit | 841a4a4e61a764b433388d8046fed2598b55dfd7 (patch) | |
tree | b8ae568baf64f2c1b834421e1b8019811eda6cd8 /lib | |
parent | 7718c9776c5903474b8f3cf958cdd18a53b2449e (diff) | |
parent | 039a83070327c09e2178ce96b8bebfff4a54a4ec (diff) | |
download | nextcloud-server-841a4a4e61a764b433388d8046fed2598b55dfd7.tar.gz nextcloud-server-841a4a4e61a764b433388d8046fed2598b55dfd7.zip |
Merge pull request #31964 from nextcloud/feat/ignore_mail_during_contact_lookup
Add setting to ignore email during search
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/Collaborators/MailPlugin.php | 7 | ||||
-rw-r--r-- | lib/private/Collaboration/Collaborators/UserPlugin.php | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index aae6f305981..8c2efce6f0d 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -51,6 +51,8 @@ class MailPlugin implements ISearchPlugin { protected $shareeEnumerationPhone; /* @var bool */ protected $shareeEnumerationFullMatch; + /* @var bool */ + protected $shareeEnumerationFullMatchEmail; /** @var IManager */ private $contactsManager; @@ -88,12 +90,17 @@ class MailPlugin implements ISearchPlugin { $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; $this->shareeEnumerationPhone = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes'; $this->shareeEnumerationFullMatch = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes'; + $this->shareeEnumerationFullMatchEmail = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_email', 'yes') === 'yes'; } /** * {@inheritdoc} */ public function search($search, $limit, $offset, ISearchResult $searchResult) { + if ($this->shareeEnumerationFullMatch && !$this->shareeEnumerationFullMatchEmail) { + return false; + } + $currentUserId = $this->userSession->getUser()->getUID(); $result = $userResults = ['wide' => [], 'exact' => []]; diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index af4d8b2ccca..12304a66ce9 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -57,6 +57,8 @@ class UserPlugin implements ISearchPlugin { /* @var bool */ protected $shareeEnumerationFullMatchUserId; /* @var bool */ + protected $shareeEnumerationFullMatchEmail; + /* @var bool */ protected $shareeEnumerationFullMatchIgnoreSecondDisplayName; /** @var IConfig */ @@ -92,6 +94,7 @@ class UserPlugin implements ISearchPlugin { $this->shareeEnumerationPhone = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes'; $this->shareeEnumerationFullMatch = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes'; $this->shareeEnumerationFullMatchUserId = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_userid', 'yes') === 'yes'; + $this->shareeEnumerationFullMatchEmail = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_email', 'yes') === 'yes'; $this->shareeEnumerationFullMatchIgnoreSecondDisplayName = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_ignore_second_display_name', 'no') === 'yes'; } @@ -185,7 +188,7 @@ class UserPlugin implements ISearchPlugin { $lowerSearch !== '' && (strtolower($uid) === $lowerSearch || strtolower($userDisplayName) === $lowerSearch || ($this->shareeEnumerationFullMatchIgnoreSecondDisplayName && trim(strtolower(preg_replace('/ \(.*\)$/', '', $userDisplayName))) === $lowerSearch) || - strtolower($userEmail ?? '') === $lowerSearch) + ($this->shareeEnumerationFullMatchEmail && strtolower($userEmail ?? '') === $lowerSearch)) ) { if (strtolower($uid) === $lowerSearch) { $foundUserById = true; |