Skip to content

Commit

Permalink
fix: try to find non-recursive share source
Browse files Browse the repository at this point in the history
instead of always picking the first one, try to find one that won't blow up

Signed-off-by: Robin Appelman <robin@icewind.nl>

[skip ci]
  • Loading branch information
icewind1991 authored and backportbot[bot] committed Aug 16, 2024
1 parent 6377b9c commit 152907e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,23 @@ private function init() {
$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(),
Expand Down

0 comments on commit 152907e

Please sign in to comment.