diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-08-17 01:22:26 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-08-17 01:22:54 +0200 |
commit | 53a888cc8130a81961dece245b35a226be4d67ab (patch) | |
tree | f5b709bb728ad16c1f68baa4cd64807f3f269b02 /lib/filesystem.php | |
parent | 70e8a7e25c40834830b0237f279d15f82dcd2a9e (diff) | |
download | nextcloud-server-53a888cc8130a81961dece245b35a226be4d67ab.tar.gz nextcloud-server-53a888cc8130a81961dece245b35a226be4d67ab.zip |
more path normalization
Diffstat (limited to 'lib/filesystem.php')
-rw-r--r-- | lib/filesystem.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/filesystem.php b/lib/filesystem.php index 6cba6b1b547..ffb8643d491 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -495,7 +495,16 @@ class OC_Filesystem{ OC_Connector_Sabre_Node::removeETagPropertyForPath($path); } - public static function normalizePath($path){ + /** + * normalize a path + * @param string path + * @param bool $stripTrailingSlash + * @return string + */ + public static function normalizePath($path,$stripTrailingSlash=true){ + if($path==''){ + return '/'; + } //no windows style slashes $path=str_replace('\\','/',$path); //add leading slash @@ -503,7 +512,7 @@ class OC_Filesystem{ $path='/'.$path; } //remove trainling slash - if(strlen($path)>1 and substr($path,-1,1)==='/'){ + if($stripTrailingSlash and strlen($path)>1 and substr($path,-1,1)==='/'){ $path=substr($path,0,-1); } //remove duplicate slashes |