From 2249bb68fccdf7fb18960a950fb22ba0f35d0a8d Mon Sep 17 00:00:00 2001
From: Louis Chemineau
'no', 'restrictUserEnumerationToPhone' => 'no', 'restrictUserEnumerationFullMatch' => 'yes', + 'shareeEnumerationIgnoreSecondDisplayName' => 'yes', 'enforceLinkPassword' => false, 'onlyShareWithGroupMembers' => false, 'shareAPIEnabled' => 'yes', @@ -158,6 +160,7 @@ public function testGetFormWithExcludedGroups(): void { ['core', 'shareapi_restrict_user_enumeration_to_group', 'no', 'no'], ['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'no'], ['core', 'shareapi_restrict_user_enumeration_full_match', 'yes', 'yes'], + ['core', 'shareapi_ignore_second_display_name', 'yes', 'yes'], ['core', 'shareapi_enabled', 'yes', 'yes'], ['core', 'shareapi_default_expire_date', 'no', 'no'], ['core', 'shareapi_expire_after_n_days', '7', '7'], @@ -191,6 +194,7 @@ public function testGetFormWithExcludedGroups(): void { 'restrictUserEnumerationToGroup' => 'no', 'restrictUserEnumerationToPhone' => 'no', 'restrictUserEnumerationFullMatch' => 'yes', + 'shareeEnumerationIgnoreSecondDisplayName' => 'yes', 'enforceLinkPassword' => false, 'onlyShareWithGroupMembers' => false, 'shareAPIEnabled' => 'yes', diff --git a/build/integration/features/bootstrap/CollaborationContext.php b/build/integration/features/bootstrap/CollaborationContext.php index bc01a32f12cf4..6bbf4453c8d1b 100644 --- a/build/integration/features/bootstrap/CollaborationContext.php +++ b/build/integration/features/bootstrap/CollaborationContext.php @@ -123,6 +123,7 @@ protected function resetAppConfigs(): void { $this->deleteServerConfig('core', 'shareapi_restrict_user_enumeration_to_phone'); $this->deleteServerConfig('core', 'shareapi_restrict_user_enumeration_full_match'); $this->deleteServerConfig('core', 'shareapi_restrict_user_enumeration_full_match_userid'); + $this->deleteServerConfig('core', 'shareapi_ignore_second_display_name'); $this->deleteServerConfig('core', 'shareapi_only_share_with_group_members'); } diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 4d8bc4cbf3ad7..ba08b96c38625 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -56,6 +56,8 @@ class UserPlugin implements ISearchPlugin { protected $shareeEnumerationFullMatch; /* @var bool */ protected $shareeEnumerationFullMatchUserId; + /* @var bool */ + protected $shareeEnumerationIgnoreSecondDisplayName; /** @var IConfig */ private $config; @@ -90,6 +92,7 @@ public function __construct(IConfig $config, $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->shareeEnumerationIgnoreSecondDisplayName = $this->config->getAppValue('core', 'shareapi_ignore_second_display_name', 'no') === 'yes'; } public function search($search, $limit, $offset, ISearchResult $searchResult) { @@ -181,6 +184,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { $this->shareeEnumerationFullMatch && $lowerSearch !== '' && (strtolower($uid) === $lowerSearch || strtolower($userDisplayName) === $lowerSearch || + (strtolower(preg_replace('/ (.*)$/', '', $userDisplayName)) === $lowerSearch && $shareeEnumerationIgnoreSecondDisplayName) || strtolower($userEmail ?? '') === $lowerSearch) ) { if (strtolower($uid) === $lowerSearch) {