Skip to content

Commit f1dde62

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: try to find non-recursive share source
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]
1 parent 37c32bc commit f1dde62

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

apps/files_sharing/lib/SharedStorage.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,23 @@ private function init() {
180180
$this->cache = new FailedCache();
181181
$this->rootPath = '';
182182
} else {
183-
$this->nonMaskedStorage = $ownerNode->getStorage();
184-
if ($this->nonMaskedStorage instanceof Wrapper && $this->nonMaskedStorage->isWrapperOf($this)) {
183+
foreach ($ownerNodes as $ownerNode) {
184+
$nonMaskedStorage = $ownerNode->getStorage();
185+
186+
// check if potential source node would lead to a recursive share setup
187+
if ($nonMaskedStorage instanceof Wrapper && $nonMaskedStorage->isWrapperOf($this)) {
188+
continue;
189+
}
190+
$this->nonMaskedStorage = $nonMaskedStorage;
191+
$this->sourcePath = $ownerNode->getPath();
192+
$this->rootPath = $ownerNode->getInternalPath();
193+
$this->cache = null;
194+
break;
195+
}
196+
if (!$this->nonMaskedStorage) {
197+
// all potential source nodes would have been recursive
185198
throw new \Exception('recursive share detected');
186199
}
187-
$this->sourcePath = $ownerNode->getPath();
188-
$this->rootPath = $ownerNode->getInternalPath();
189200
$this->storage = new PermissionsMask([
190201
'storage' => $this->nonMaskedStorage,
191202
'mask' => $this->superShare->getPermissions(),

0 commit comments

Comments
 (0)