From 2e0d5bd9e562c85ec858bff229b70467efd9f546 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 21 Aug 2023 19:45:03 +0200 Subject: [PATCH] add some recrusive detection/prevention Signed-off-by: Robin Appelman --- apps/files_sharing/lib/SharedStorage.php | 6 +++--- lib/private/Files/Storage/Wrapper/Wrapper.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 53e9f60947e0b..d9c71dd2ad402 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -41,6 +41,7 @@ use OC\Files\Storage\FailedStorage; use OC\Files\Storage\Home; use OC\Files\Storage\Wrapper\PermissionsMask; +use OC\Files\Storage\Wrapper\Wrapper; use OC\User\NoUserException; use OCA\Files_External\Config\ExternalMountPoint; use OCP\Constants; @@ -410,11 +411,10 @@ public function getCache($path = '', $storage = null) { return new FailedCache(); } - $this->cache = new Cache( + $this->cache = new \OCA\Files_Sharing\Cache( $storage, $sourceRoot, - \OC::$server->get(CacheDependencies::class), - $this->getShare() + \OC::$server->get(DisplayNameCache::class) ); return $this->cache; } diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 9f5564b449038..665914df2a722 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -654,4 +654,15 @@ public function writeStream(string $path, $stream, int $size = null): int { public function getDirectoryContent($directory): \Traversable { return $this->getWrapperStorage()->getDirectoryContent($directory); } + + public function isWrapperOf(IStorage $storage) { + $wrapped = $this->getWrapperStorage(); + if ($wrapped === $storage) { + return true; + } + if ($wrapped instanceof Wrapper) { + return $wrapped->isWrapperOf($storage); + } + return false; + } }