Skip to content

Commit 4f74f3d

Browse files
committed
Use email settings in DAV search
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 883e6b5 commit 4f74f3d

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

apps/dav/lib/Connector/Sabre/Principal.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof'
271271
$limitEnumerationPhone = $this->shareManager->limitEnumerationToPhone();
272272
$allowEnumerationFullMatch = $this->shareManager->allowEnumerationFullMatch();
273273
$ignoreSecondDisplayName = $this->shareManager->ignoreSecondDisplayName();
274+
$matchEmail = $this->shareManager->matchEmail();
274275

275276
// If sharing is restricted to group members only,
276277
// return only members that have groups in common
@@ -299,7 +300,7 @@ protected function searchUserPrincipals(array $searchProperties, $test = 'allof'
299300
switch ($prop) {
300301
case '{http://sabredav.org/ns}email-address':
301302
if (!$allowEnumeration) {
302-
if ($allowEnumerationFullMatch) {
303+
if ($allowEnumerationFullMatch && $matchEmail) {
303304
$users = $this->userManager->getByEmail($value);
304305
} else {
305306
$users = [];

apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ public function testSearchPrincipalWithEnumerationDisabledEmail(): void {
662662
->method('allowEnumerationFullMatch')
663663
->willReturn(true);
664664

665+
$this->shareManager->expects($this->once())
666+
->method('matchEmail')
667+
->willReturn(true);
668+
665669
$user2 = $this->createMock(IUser::class);
666670
$user2->method('getUID')->willReturn('user2');
667671
$user2->method('getDisplayName')->willReturn('User 2');

lib/private/Share20/Manager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,10 @@ public function allowEnumerationFullMatch(): bool {
19151915
return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes';
19161916
}
19171917

1918+
public function matchEmail(): bool {
1919+
return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_email', 'yes') === 'yes';
1920+
}
1921+
19181922
public function ignoreSecondDisplayName(): bool {
19191923
return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_ignore_second_display_name', 'no') === 'yes';
19201924
}

lib/public/Share/IManager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,19 @@ public function limitEnumerationToPhone(): bool;
448448
*/
449449
public function allowEnumerationFullMatch(): bool;
450450

451+
/**
452+
* Check if the search should match the email
453+
*
454+
* @return bool
455+
* @since 25.0.0
456+
*/
457+
public function matchEmail(): bool;
458+
451459
/**
452460
* Check if the search should ignore the second in parentheses display name if there is any
453461
*
454462
* @return bool
455-
* @since 24.0.0
463+
* @since 25.0.0
456464
*/
457465
public function ignoreSecondDisplayName(): bool;
458466

0 commit comments

Comments
 (0)