Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-03-11 19:21:26 +0400
committerLukas Reschke <lukas@statuscode.ch>2013-03-11 19:47:30 +0400
commitedf7162762fc425df1ec2ce7149c18a0af82a3b8 (patch)
tree082c26627a1f79c327c4cb6323af318313fc9cb2
parent0de2c955fc356289439d7accef705d7546552d02 (diff)
Check if username is valid and remove slashes from filename
Backport of #2236 to stable45
-rw-r--r--lib/migrate.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/migrate.php b/lib/migrate.php
index 8d3610c9309..8465eedc981 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -234,11 +234,20 @@ class OC_Migrate{
OC_Log::write( 'migration', 'User doesn\'t exist', OC_Log::ERROR );
return json_encode( array( 'success' => false ) );
}
+
+ // Check if the username is valid
+ if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $json->exporteduser )) {
+ OC_Log::write( 'migration', 'Username is not valid', OC_Log::ERROR );
+ return json_encode( array( 'success' => false ) );
+ }
+
// Copy data
$userfolder = $extractpath . $json->exporteduser;
$newuserfolder = $datadir . '/' . self::$uid;
foreach(scandir($userfolder) as $file){
- if($file !== '.' && $file !== '..' && is_dir($file)){
+ if($file !== '.' && $file !== '..' && is_dir($file)) {
+ $file = str_replace(array('/', '\\'), '', $file);
+
// Then copy the folder over
OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file);
}