mirror of
https://github.com/nextcloud/server.git
synced 2026-04-23 07:08:34 -04:00
Use share setting in DAV search
shareapi_restrict_user_enumeration_full_match_ignore_second_display_name was introduced to ignore second display name during search from the share panel. But this setting was not respected by search from the calendar application. This fix it. Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
13dbad0080
commit
70c56b411e
3 changed files with 16 additions and 2 deletions
|
|
@ -270,6 +270,7 @@ class Principal implements BackendInterface {
|
|||
$limitEnumerationGroup = $this->shareManager->limitEnumerationToGroups();
|
||||
$limitEnumerationPhone = $this->shareManager->limitEnumerationToPhone();
|
||||
$allowEnumerationFullMatch = $this->shareManager->allowEnumerationFullMatch();
|
||||
$ignoreSecondDisplayName = $this->shareManager->ignoreSecondDisplayName();
|
||||
|
||||
// If sharing is restricted to group members only,
|
||||
// return only members that have groups in common
|
||||
|
|
@ -349,8 +350,9 @@ class Principal implements BackendInterface {
|
|||
if ($allowEnumerationFullMatch) {
|
||||
$lowerSearch = strtolower($value);
|
||||
$users = $this->userManager->searchDisplayName($value, $searchLimit);
|
||||
$users = \array_filter($users, static function (IUser $user) use ($lowerSearch) {
|
||||
return strtolower($user->getDisplayName()) === $lowerSearch;
|
||||
$users = \array_filter($users, static function (IUser $user) use ($lowerSearch, $ignoreSecondDisplayName) {
|
||||
$lowerDisplayName = strtolower($user->getDisplayName());
|
||||
return $lowerDisplayName === $lowerSearch || ($ignoreSecondDisplayName && trim(preg_replace('/ \(.*\)$/', '', $lowerDisplayName)) === $lowerSearch);
|
||||
});
|
||||
} else {
|
||||
$users = [];
|
||||
|
|
|
|||
|
|
@ -1963,6 +1963,10 @@ class Manager implements IManager {
|
|||
return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes';
|
||||
}
|
||||
|
||||
public function ignoreSecondDisplayName(): bool {
|
||||
return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_ignore_second_display_name', 'no') === 'yes';
|
||||
}
|
||||
|
||||
public function currentUserCanEnumerateTargetUser(?IUser $currentUser, IUser $targetUser): bool {
|
||||
if ($this->allowEnumerationFullMatch()) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -454,6 +454,14 @@ interface IManager {
|
|||
*/
|
||||
public function allowEnumerationFullMatch(): bool;
|
||||
|
||||
/**
|
||||
* Check if the search should ignore the second in parentheses display name if there is any
|
||||
*
|
||||
* @return bool
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function ignoreSecondDisplayName(): bool;
|
||||
|
||||
/**
|
||||
* Check if the current user can enumerate the target user
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue