diff options
Diffstat (limited to 'lib/files/filesystem.php')
-rw-r--r-- | lib/files/filesystem.php | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 4b445588a65..1850d50f971 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -221,7 +221,11 @@ class Filesystem { $parser = new \OC\ArrayParser(); $root = \OC_User::getHome($user); - self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); + if (\OC\Files\Cache\Cache::storageExists('local::' . $root . '/') or is_null($user)) { + self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); + } else { + self::mount('\OC\Files\Storage\Home', array('user' => $user, 'datadir' => $root), $user); + } $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); //move config file to it's new position @@ -585,18 +589,32 @@ class Filesystem { } //no windows style slashes $path = str_replace('\\', '/', $path); + //add leading slash if ($path[0] !== '/') { $path = '/' . $path; } - //remove duplicate slashes - while (strpos($path, '//') !== false) { - $path = str_replace('//', '/', $path); + + // remove '/./' + // ugly, but str_replace() can't replace them all in one go + // as the replacement itself is part of the search string + // which will only be found during the next iteration + while (strpos($path, '/./') !== false) { + $path = str_replace('/./', '/', $path); } + // remove sequences of slashes + $path = preg_replace('#/{2,}#', '/', $path); + //remove trailing slash if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') { $path = substr($path, 0, -1); } + + // remove trailing '/.' + if (substr($path, -2) == '/.') { + $path = substr($path, 0, -2); + } + //normalize unicode if possible $path = \OC_Util::normalizeUnicode($path); return $path; |