Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Return early if path is root
Signed-off-by: J0WI <[email protected]>
  • Loading branch information
J0WI committed Apr 5, 2021
commit 0c9b8ad051b72ca5fe4e24dc6290f939ddd60bd0
16 changes: 8 additions & 8 deletions lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,6 @@ public static function hasUpdated($path, $time) {
* @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
Expand All @@ -812,16 +808,20 @@ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsol
*/
$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);
Expand Down