diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 1c82c46f9fb82..c3f5d0acc0278 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1533,8 +1533,29 @@ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool } if ($share->getShareType() === IShare::TYPE_CIRCLE) { - // TODO: have a sanity check like above? - return true; + if ( + Server::get(IAppManager::class)->isEnabledForUser('circles') + && class_exists('\OCA\Circles\Api\v1\Circles') + ) { + $hasCircleId = (str_ends_with($share->getSharedWith(), ']')); + $shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0); + $shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' ')); + if ($shareWithLength === false) { + $sharedWith = substr($share->getSharedWith(), $shareWithStart); + } else { + $sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength); + } + try { + $member = Circles::getMember($sharedWith, $this->userId, 1); + if ($member->getLevel() >= 1) { + return true; + } + return false; + } catch (\Exception $e) { + return false; + } + } + return false; } if ($share->getShareType() === IShare::TYPE_ROOM) { diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index ad09464c36626..bc1dfda9aca42 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1680,6 +1680,7 @@ +