From fc834d4ebb773458ffd4e9e651d39277c827b3af Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Tue, 19 Apr 2022 12:54:28 +0200 Subject: [PATCH] Use email settings in DAV search Signed-off-by: Louis Chemineau --- apps/dav/lib/Connector/Sabre/Principal.php | 3 ++- apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 358dd732ea012..e597b52f84f77 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -266,6 +266,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof' $limitEnumerationPhone = $this->shareManager->limitEnumerationToPhone(); $allowEnumerationFullMatch = $this->shareManager->allowEnumerationFullMatch(); $ignoreSecondDisplayName = $this->shareManager->ignoreSecondDisplayName(); + $matchEmail = $this->shareManager->matchEmail(); // If sharing is restricted to group members only, // return only members that have groups in common @@ -294,7 +295,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof' switch ($prop) { case '{http://sabredav.org/ns}email-address': if (!$allowEnumeration) { - if ($allowEnumerationFullMatch) { + if ($allowEnumerationFullMatch && $matchEmail) { $users = $this->userManager->getByEmail($value); } else { $users = []; diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php index 39bb41688dc05..b9dd5be184303 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php @@ -633,6 +633,10 @@ public function testSearchPrincipalWithEnumerationDisabledEmail() { ->method('allowEnumerationFullMatch') ->willReturn(true); + $this->shareManager->expects($this->once()) + ->method('matchEmail') + ->willReturn(true); + $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); $user2->method('getDisplayName')->willReturn('User 2');