Skip to content

Commit 2612a49

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 f51c4f7 commit 2612a49

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
@@ -1510,8 +1510,29 @@ protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups =
15101510
}
15111511

15121512
if ($share->getShareType() === IShare::TYPE_CIRCLE) {
1513-
// TODO: have a sanity check like above?
1514-
return true;
1513+
if (
1514+
Server::get(IAppManager::class)->isEnabledForUser('circles')
1515+
&& class_exists('\OCA\Circles\Api\v1\Circles')
1516+
) {
1517+
$hasCircleId = (str_ends_with($share->getSharedWith(), ']'));
1518+
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
1519+
$shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' '));
1520+
if ($shareWithLength === false) {
1521+
$sharedWith = substr($share->getSharedWith(), $shareWithStart);
1522+
} else {
1523+
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
1524+
}
1525+
try {
1526+
$member = Circles::getMember($sharedWith, $this->userId, 1);
1527+
if ($member->getLevel() >= 1) {
1528+
return true;
1529+
}
1530+
return false;
1531+
} catch (\Exception $e) {
1532+
return false;
1533+
}
1534+
}
1535+
return false;
15151536
}
15161537

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

0 commit comments

Comments
 (0)