From 1b7bf74f7717619ef75c1087da0ebe3607c43ad0 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 28 Oct 2026 12:34:24 +0100 Subject: [PATCH] fix: Don't auto complete nor allow sharing to disabled users Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Carl Schwan --- apps/files_sharing/lib/Controller/ShareAPIController.php | 4 ++++ lib/private/Collaboration/Collaborators/MailPlugin.php | 2 +- lib/private/Collaboration/Collaborators/RemotePlugin.php | 2 +- tests/lib/Collaboration/Collaborators/MailPluginTest.php | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 1ef197c353947..cb22e14aec0ac 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -720,6 +720,10 @@ public function createShare( if ($shareWith === null || !$this->userManager->userExists($shareWith)) { throw new OCSNotFoundException($this->l->t('Please specify a valid account to share with')); } + $shareWithUser = $this->userManager->get($shareWith); + if ($shareWithUser !== null && !$shareWithUser->isEnabled()) { + throw new OCSForbiddenException($this->l->t('Cannot share with a disabled account.')); + } $share->setSharedWith($shareWith); $share->setPermissions($permissions); } elseif ($shareType === IShare::TYPE_GROUP) { diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 85649b70bca6b..02ba8a45b4486 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -127,7 +127,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b if (isset($contact['isLocalSystemBook'])) { $contactUser = $this->userManager->get($contact['UID']); - if ($contactUser === null) { + if ($contactUser === null || !$contactUser->isEnabled()) { continue; } diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index 5dd17c9527bf7..5e6afa6f8e617 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -73,7 +73,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b } $localUser = $this->userManager->get($remoteUser); - if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { + if ($localUser !== null && $localUser->isEnabled() && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { $result['wide'][] = [ 'label' => $contact['FN'], 'uuid' => $contact['UID'], diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index a50fc251c25b6..ac0848b319bb5 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -58,6 +58,9 @@ protected function setUp(): void { $user ->method('getUID') ->willReturn($uid); + $user + ->method('isEnabled') + ->willReturn(!str_starts_with($uid, 'disabled')); return $user; });