diff options
author | Robin Appelman <robin@icewind.nl> | 2023-10-25 16:43:57 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-11-02 14:21:08 +0100 |
commit | 8f7f696110aae155e5e29eacc13b33da0c5047d6 (patch) | |
tree | bac57add83bc2c68822f30f7037d24becf3032fe | |
parent | b2c0cd9e266d82382d101da195e7745ebe0accfd (diff) | |
download | nextcloud-server-8f7f696110aae155e5e29eacc13b33da0c5047d6.tar.gz nextcloud-server-8f7f696110aae155e5e29eacc13b33da0c5047d6.zip |
remove some unneeded normalizePath callsnormlize-less
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Cache/Updater.php | 3 | ||||
-rw-r--r-- | lib/private/Files/Mount/MountPoint.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Node/Node.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Jail.php | 20 | ||||
-rw-r--r-- | lib/private/Files/View.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_Helper.php | 2 |
7 files changed, 27 insertions, 16 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index c56bcaebb12..6d9b9a62e4a 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -112,7 +112,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto parent::__construct([ 'storage' => null, - 'root' => null, + 'root' => '', ]); } @@ -292,12 +292,16 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto case 'xb': case 'a': case 'ab': - $creatable = $this->isCreatable(dirname($path)); + $parent = dirname($path); + if ($parent === '.') { + $parent = ''; + } + $creatable = $this->isCreatable($parent); $updatable = $this->isUpdatable($path); // if neither permissions given, no need to continue if (!$creatable && !$updatable) { if (pathinfo($path, PATHINFO_EXTENSION) === 'part') { - $updatable = $this->isUpdatable(dirname($path)); + $updatable = $this->isUpdatable($parent); } if (!$updatable) { diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index 457dd207e9d..1a9a0f0b68e 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -255,6 +255,9 @@ class Updater implements IUpdater { private function correctParentStorageMtime($internalPath) { $parentId = $this->cache->getParentId($internalPath); $parent = dirname($internalPath); + if ($parent === '.') { + $parent = ''; + } if ($parentId != -1) { $mtime = $this->storage->filemtime($parent); if ($mtime !== false) { diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index fe6358b32f1..10711154f14 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -246,7 +246,7 @@ class MountPoint implements IMountPoint { * @return string */ private function formatPath($path) { - $path = Filesystem::normalizePath($path); + $path = '/' . trim($path, '/'); if (strlen($path) > 1) { $path .= '/'; } diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 385d45f1e3e..082851a2888 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -70,8 +70,8 @@ class Node implements INode { * @param FileInfo $fileInfo */ public function __construct(IRootFolder $root, $view, $path, $fileInfo = null, ?INode $parent = null, bool $infoHasSubMountsIncluded = true) { - if (Filesystem::normalizePath($view->getRoot()) !== '/') { - throw new PreConditionNotMetException('The view passed to the node should not have any fake root set'); + if ($view->getRoot() !== '') { + throw new PreConditionNotMetException('The view passed to the node should not have any fake root set: ' . $view->getRoot()); } $this->view = $view; $this->root = $root; diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 1921ac27848..b66d7d8e0fc 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -30,7 +30,6 @@ namespace OC\Files\Storage\Wrapper; use OC\Files\Cache\Wrapper\CacheJail; use OC\Files\Cache\Wrapper\JailPropagator; -use OC\Files\Filesystem; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; use OCP\Lock\ILockingProvider; @@ -42,9 +41,9 @@ use OCP\Lock\ILockingProvider; */ class Jail extends Wrapper { /** - * @var string + * Root of the jail, without trailing slash */ - protected $rootPath; + protected string $rootPath; /** * @param array $arguments ['storage' => $storage, 'root' => $root] @@ -54,11 +53,18 @@ class Jail extends Wrapper { */ public function __construct($arguments) { parent::__construct($arguments); - $this->rootPath = $arguments['root']; + $this->rootPath = trim($arguments['root'], '/'); } public function getUnjailedPath($path) { - return trim(Filesystem::normalizePath($this->rootPath . '/' . $path), '/'); + $path = trim($path, '/'); + if ($this->rootPath === '') { + return $path; + } elseif ($path === '') { + return $this->rootPath; + } else { + return $this->rootPath . '/' . $path; + } } /** @@ -70,9 +76,7 @@ class Jail extends Wrapper { public function getJailedPath($path) { - $root = rtrim($this->rootPath, '/') . '/'; - - if ($path !== $this->rootPath && !str_starts_with($path, $root)) { + if ($path !== $this->rootPath && !str_starts_with($path, $this->rootPath . '/')) { return null; } else { $path = substr($path, strlen($this->rootPath)); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 86651ab3e1a..fef6a192906 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1522,7 +1522,7 @@ class View { $rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)); } - $rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/ + $rootEntry['path'] = substr($path . '/' . $rootEntry['name'], strlen($user) + 2); // full path without /$user/ // if sharing was disabled for the user we remove the share permissions if (\OCP\Util::isSharingDisabledForUser()) { diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index cf39d045ae9..4bf1cc81f1e 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -491,7 +491,7 @@ class OC_Helper { if (!$view) { throw new \OCP\Files\NotFoundException(); } - $fullPath = Filesystem::normalizePath($view->getAbsolutePath($path)); + $fullPath = rtrim($view->getAbsolutePath($path), '/'); $cacheKey = $fullPath. '::' . ($includeMountPoints ? 'include' : 'exclude'); if ($useCache) { |