summaryrefslogtreecommitdiffstats
path: root/lib/files.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-01-16 03:06:11 +0100
committerRobin Appelman <icewind@owncloud.com>2012-01-16 03:06:11 +0100
commit96e2f15d8a6eee83e30bdf77ef3582f0c26b52e0 (patch)
tree9df43704cb7e580d328d6780561a0ec146003e7b /lib/files.php
parentccc43f0ea02a048583fff715f00cda0280124586 (diff)
parentb0dbca0cc7f2d07dbf01c54861b932d8dc9fe2df (diff)
downloadnextcloud-server-96e2f15d8a6eee83e30bdf77ef3582f0c26b52e0.tar.gz
nextcloud-server-96e2f15d8a6eee83e30bdf77ef3582f0c26b52e0.zip
merge master into filesystem
Diffstat (limited to 'lib/files.php')
-rw-r--r--lib/files.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/files.php b/lib/files.php
index 143aab5c72d..5686287ecc4 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -152,8 +152,8 @@ class OC_Files {
*/
public static function move($sourceDir,$source,$targetDir,$target){
if(OC_User::isLoggedIn()){
- $targetFile=$targetDir.'/'.$target;
- $sourceFile=$sourceDir.'/'.$source;
+ $targetFile=self::normalizePath($targetDir.'/'.$target);
+ $sourceFile=self::normalizePath($sourceDir.'/'.$source);
return OC_Filesystem::rename($sourceFile,$targetFile);
}
}
@@ -274,4 +274,19 @@ class OC_Files {
$content.= "Options -Indexes\n";
@file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
}
+
+ /**
+ * normalize a path, removing any double, add leading /, etc
+ * @param string $path
+ * @return string
+ */
+ static public function normalizePath($path){
+ $path='/'.$path;
+ $old='';
+ while($old!=$path){//replace any multiplicity of slashes with a single one
+ $old=$path;
+ $path=str_replace('//','/',$path);
+ }
+ return $path;
+ }
}