Skip to content

Commit a6c557c

Browse files
committed
Match against share target and node path
Signed-off-by: Julius Härtl <[email protected]>
1 parent 62f507e commit a6c557c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/private/Share20/Manager.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
use OCP\Files\IRootFolder;
5353
use OCP\Files\Mount\IMountManager;
5454
use OCP\Files\Node;
55+
use OCP\Files\NotFoundException;
5556
use OCP\HintException;
5657
use OCP\IConfig;
5758
use OCP\IGroupManager;
@@ -292,10 +293,18 @@ protected function generalCreateChecks(IShare $share) {
292293
$permissions = 0;
293294

294295
if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
295-
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share) {
296+
try {
297+
$targetNode = $share->getTarget() ? $userFolder->get($share->getTarget()) : null;
298+
} catch (NotFoundException $e) {
299+
$targetNode = null;
300+
}
301+
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share, $targetNode) {
296302
// We need to filter since there might be other mountpoints that contain the file
297303
// e.g. if the user has access to the same external storage that the file is originating from
298-
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && $mount->getPath() === $share->getNode()->getPath();
304+
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && (
305+
$targetNode ? $targetNode->getPath() === $mount->getPath() :
306+
$mount->getPath() === $share->getNode()->getPath()
307+
);
299308
});
300309
$userMount = array_shift($userMounts);
301310
if ($userMount === null) {

0 commit comments

Comments
 (0)