Skip to content

Commit 6e515f5

Browse files
cristianscheidartonge
authored andcommitted
fix(share-api-controller): add sanity check on canAccessShare for circle share types
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent bff9aaf commit 6e515f5

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,8 +1525,29 @@ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool
15251525
}
15261526

15271527
if ($share->getShareType() === IShare::TYPE_CIRCLE) {
1528-
// TODO: have a sanity check like above?
1529-
return true;
1528+
if (
1529+
Server::get(IAppManager::class)->isEnabledForUser('circles')
1530+
&& class_exists('\OCA\Circles\Api\v1\Circles')
1531+
) {
1532+
$hasCircleId = (str_ends_with($share->getSharedWith(), ']'));
1533+
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
1534+
$shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' '));
1535+
if ($shareWithLength === false) {
1536+
$sharedWith = substr($share->getSharedWith(), $shareWithStart);
1537+
} else {
1538+
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
1539+
}
1540+
try {
1541+
$member = Circles::getMember($sharedWith, $this->userId, 1);
1542+
if ($member->getLevel() >= 1) {
1543+
return true;
1544+
}
1545+
return false;
1546+
} catch (\Exception $e) {
1547+
return false;
1548+
}
1549+
}
1550+
return false;
15301551
}
15311552

15321553
if ($share->getShareType() === IShare::TYPE_ROOM) {

0 commit comments

Comments
 (0)