diff options
author | Stephan Orbaugh <62374139+sorbaugh@users.noreply.github.com> | 2024-08-01 16:55:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 16:55:59 +0200 |
commit | 5faa9033636b44ab9e7bb304d9cb35d6ce4e67ac (patch) | |
tree | b5412aa61d51a643b72c53e226ea3967b68d0e6b /apps/files_sharing | |
parent | abd7514c5e9a3578ea6c27547af0907927585136 (diff) | |
parent | 7343da4a9ce4ac23b964dc8a2e08f5445bdc099b (diff) | |
download | nextcloud-server-5faa9033636b44ab9e7bb304d9cb35d6ce4e67ac.tar.gz nextcloud-server-5faa9033636b44ab9e7bb304d9cb35d6ce4e67ac.zip |
Merge pull request #46881 from nextcloud/try-non-recursive-source
fix: try to find non-recursive share source
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 2870c14a2bd..f8b318dcc5b 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -145,18 +145,30 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto $rootFolder = \OC::$server->get(IRootFolder::class); $this->ownerUserFolder = $rootFolder->getUserFolder($this->superShare->getShareOwner()); $sourceId = $this->superShare->getNodeId(); - $ownerNode = $this->ownerUserFolder->getFirstNodeById($sourceId); - if (!$ownerNode) { + $ownerNodes = $this->ownerUserFolder->getById($sourceId); + + if (count($ownerNodes) === 0) { $this->storage = new FailedStorage(['exception' => new NotFoundException("File by id $sourceId not found")]); $this->cache = new FailedCache(); $this->rootPath = ''; } else { - $this->nonMaskedStorage = $ownerNode->getStorage(); - if ($this->nonMaskedStorage instanceof Wrapper && $this->nonMaskedStorage->isWrapperOf($this)) { + foreach ($ownerNodes as $ownerNode) { + $nonMaskedStorage = $ownerNode->getStorage(); + + // check if potential source node would lead to a recursive share setup + if ($nonMaskedStorage instanceof Wrapper && $nonMaskedStorage->isWrapperOf($this)) { + continue; + } + $this->nonMaskedStorage = $nonMaskedStorage; + $this->sourcePath = $ownerNode->getPath(); + $this->rootPath = $ownerNode->getInternalPath(); + $this->cache = null; + break; + } + if (!$this->nonMaskedStorage) { + // all potential source nodes would have been recursive throw new \Exception('recursive share detected'); } - $this->sourcePath = $ownerNode->getPath(); - $this->rootPath = $ownerNode->getInternalPath(); $this->storage = new PermissionsMask([ 'storage' => $this->nonMaskedStorage, 'mask' => $this->superShare->getPermissions(), |