diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-11-07 10:52:37 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-11-17 10:48:15 +0100 |
commit | 0ab973a3a6ba9c0c98f7414fa620c72bc356e286 (patch) | |
tree | 7a801019fb902a3ec7effdcb3d262915779647b9 /lib/private/files/filesystem.php | |
parent | 39ae569c5cafda5e15865699ff17b9734020329e (diff) | |
download | nextcloud-server-0ab973a3a6ba9c0c98f7414fa620c72bc356e286.tar.gz nextcloud-server-0ab973a3a6ba9c0c98f7414fa620c72bc356e286.zip |
Make it possible to cleanPath() absolute Windows paths
Diffstat (limited to 'lib/private/files/filesystem.php')
-rw-r--r-- | lib/private/files/filesystem.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index c7dc99c55cb..6c8fa8c90ba 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -698,13 +698,22 @@ class Filesystem { * @param bool $stripTrailingSlash * @return string */ - public static function normalizePath($path, $stripTrailingSlash = true) { + public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) { if ($path == '') { return '/'; } + //no windows style slashes $path = str_replace('\\', '/', $path); + // When normalizing an absolute path, we need to ensure that the drive-letter + // is still at the beginning on windows + $windows_drive_letter = ''; + if ($isAbsolutePath && \OC_Util::runningOnWindows() && preg_match('#^([a-zA-Z])$#', $path[0]) && $path[1] == ':' && $path[2] == '/') { + $windows_drive_letter = substr($path, 0, 2); + $path = substr($path, 2); + } + //add leading slash if ($path[0] !== '/') { $path = '/' . $path; @@ -733,7 +742,7 @@ class Filesystem { //normalize unicode if possible $path = \OC_Util::normalizeUnicode($path); - return $path; + return $windows_drive_letter . $path; } /** |