summaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2021-06-23 15:21:56 +0200
committerGitHub <noreply@github.com>2021-06-23 15:21:56 +0200
commita70fd1bad1626e67982ac59d8b3da486ffad70c5 (patch)
tree1a20e8a6b3d858d67796699125d4b60c89019c96 /lib/private/Files
parenteceef4c747d8650448317ef94a5c4af139a007d6 (diff)
parent0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0 (diff)
downloadnextcloud-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.php16
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);