diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 7fc5c8e3191ad..5366c0923778b 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -92,7 +92,11 @@ protected function getJailedPath(string $path, ?string $root = null) { protected function formatCacheEntry($entry) { if (isset($entry['path'])) { - $entry['path'] = $this->getJailedPath($entry['path']); + $sourcePath = $entry['path']; + $entry['path'] = $this->getJailedPath($sourcePath); + if (is_null($entry['path'])) { + $this->logger->error("'$sourcePath' is not inside jail path {$this->root}", ['entry' => $entry]); + } } return $entry; } diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index bf23f1cc30ab0..8149ea19419f0 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -27,6 +27,7 @@ public function __construct(?ICache $cache, ?CacheDependencies $dependencies = n $this->mimetypeLoader = $cache->mimetypeLoader; $this->connection = $cache->connection; $this->querySearchHelper = $cache->querySearchHelper; + $this->logger = $cache->logger; } else { if (!$dependencies) { $dependencies = Server::get(CacheDependencies::class); @@ -34,6 +35,7 @@ public function __construct(?ICache $cache, ?CacheDependencies $dependencies = n $this->mimetypeLoader = $dependencies->getMimeTypeLoader(); $this->connection = $dependencies->getConnection(); $this->querySearchHelper = $dependencies->getQuerySearchHelper(); + $this->logger = $dependencies->getLogger(); } } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index ecf2f438edb1f..5987188067153 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1527,6 +1527,9 @@ public function getDirectoryContent($directory, $mimetype_filter = '', ?\OCP\Fil if ($sharingDisabled) { $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } + if (is_null($content['path'])) { + throw new \Exception('Directory listing of "' . $path . '" contains item with null path (' . $content['fileid'] . ')'); + } $ownerId = $storage->getOwner($content['path']); if ($ownerId !== false) { $owner = $this->getUserObjectForOwner($ownerId);