Skip to content

Commit 4f3d446

Browse files
authored
Merge pull request #5011 from nextcloud/backport/5010/stable31
[stable31] fix(SecureView): do not rely on specualtive getMountPoint()
2 parents cbe5e5f + 0134d96 commit 4f3d446

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/Storage/SecureViewWrapper.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use OC\Files\Storage\Wrapper\Wrapper;
1212
use OCA\Richdocuments\Middleware\WOPIMiddleware;
1313
use OCA\Richdocuments\PermissionManager;
14-
use OCP\Files\Folder;
1514
use OCP\Files\ForbiddenException;
1615
use OCP\Files\IRootFolder;
1716
use OCP\Files\NotFoundException;
@@ -90,16 +89,15 @@ private function shouldSecure(string $path, ?IStorage $sourceStorage = null): bo
9089
fclose($fp);
9190
}
9291

93-
$storage = $sourceStorage ?? $this;
94-
95-
$isSharedStorage = $storage->instanceOfStorage(ISharedStorage::class);
96-
$mountNode = $this->rootFolder->get($storage->getMountPoint());
9792
try {
98-
$node = $mountNode instanceof Folder ? $mountNode->get($path) : $mountNode;
99-
} catch (NotFoundException $e) {
93+
$node = $this->rootFolder->get($this->mountPoint . $path);
94+
} catch (NotFoundException) {
10095
// If the file is just created we may need to check the parent as this is only just about figuring out if it is a share
101-
$node = $mountNode->get(dirname($path));
96+
$node = $this->rootFolder->get(dirname($this->mountPoint . $path));
10297
}
98+
99+
$isSharedStorage = $node->getStorage()->instanceOfStorage(ISharedStorage::class);
100+
103101
$share = $isSharedStorage ? $node->getStorage()->getShare() : null;
104102
$userId = $this->userSession->getUser()?->getUID();
105103

0 commit comments

Comments
 (0)