[Pkg-owncloud-commits] [owncloud] 29/74: Make it possible to cleanPath() absolute Windows paths

David Prévot taffit at moszumanska.debian.org
Tue Dec 2 22:04:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit e3a9a19d95016a10eb55afb083b73155cf0b6f69
Author: Joas Schilling <nickvergessen at gmx.de>
Date:   Fri Nov 7 10:52:37 2014 +0100

    Make it possible to cleanPath() absolute Windows paths
---
 lib/private/files/filesystem.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index f5be7a0..1ebc790 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -695,13 +695,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;
@@ -730,7 +739,7 @@ class Filesystem {
 		//normalize unicode if possible
 		$path = \OC_Util::normalizeUnicode($path);
 
-		return $path;
+		return $windows_drive_letter . $path;
 	}
 
 	/**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list