aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorStephan Orbaugh <62374139+sorbaugh@users.noreply.github.com>2024-08-19 18:27:10 +0200
committerGitHub <noreply@github.com>2024-08-19 18:27:10 +0200
commit9f1c6d7cd4f7dfa1aac81865ab5daa56cd9908ec (patch)
tree16f755f08301d7c22f5a4d8371b5afefa51e87a9 /apps
parentedd8a03a504f728fe8ef4a15d5dbe92b8fbfeab2 (diff)
parent0571aa16eade91189ad07201f2a9cc6376df1538 (diff)
downloadnextcloud-server-9f1c6d7cd4f7dfa1aac81865ab5daa56cd9908ec.tar.gz
nextcloud-server-9f1c6d7cd4f7dfa1aac81865ab5daa56cd9908ec.zip
Merge pull request #47279 from nextcloud/backport/46881/stable28
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/SharedStorage.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 413a4460ad3..40eb06faa9e 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -171,19 +171,29 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
$this->ownerUserFolder = $rootFolder->getUserFolder($this->superShare->getShareOwner());
$sourceId = $this->superShare->getNodeId();
$ownerNodes = $this->ownerUserFolder->getById($sourceId);
- /** @var Node|false $ownerNode */
- $ownerNode = current($ownerNodes);
- if (!$ownerNode) {
+
+ 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(),