diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-06-23 15:21:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 15:21:56 +0200 |
commit | a70fd1bad1626e67982ac59d8b3da486ffad70c5 (patch) | |
tree | 1a20e8a6b3d858d67796699125d4b60c89019c96 /lib/private/Files | |
parent | eceef4c747d8650448317ef94a5c4af139a007d6 (diff) | |
parent | 0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0 (diff) | |
download | nextcloud-server-a70fd1bad1626e67982ac59d8b3da486ffad70c5.tar.gz nextcloud-server-a70fd1bad1626e67982ac59d8b3da486ffad70c5.zip |
Merge pull request #26344 from J0WI/fs-early-root
Return early if path is root
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/Filesystem.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 0b7e96bbba3..131c0780dce 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -777,10 +777,6 @@ class Filesystem { * @return string */ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) { - if (is_null(self::$normalizedPathCache)) { - self::$normalizedPathCache = new CappedMemoryCache(2048); - } - /** * FIXME: This is a workaround for existing classes and files which call * this function with another type than a valid string. This @@ -789,16 +785,20 @@ class Filesystem { */ $path = (string)$path; + if ($path === '') { + return '/'; + } + + if (is_null(self::$normalizedPathCache)) { + self::$normalizedPathCache = new CappedMemoryCache(2048); + } + $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]); if ($cacheKey && isset(self::$normalizedPathCache[$cacheKey])) { return self::$normalizedPathCache[$cacheKey]; } - if ($path === '') { - return '/'; - } - //normalize unicode if possible if (!$keepUnicode) { $path = \OC_Util::normalizeUnicode($path); |