summaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorJ0WI <J0WI@users.noreply.github.com>2021-03-27 14:47:58 +0100
committerJ0WI <J0WI@users.noreply.github.com>2021-04-05 17:19:34 +0200
commit0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0 (patch)
tree429317c3f49051f9616db8d0680202d08e650aae /lib/private/Files
parentbfd926938f5c26f22fb453ad24b62817170dd2a4 (diff)
downloadnextcloud-server-0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0.tar.gz
nextcloud-server-0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0.zip
Return early if path is root
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
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 fade3b69fbb..54127b6c989 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -800,10 +800,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
@@ -812,16 +808,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);