Skip to content
Snippets Groups Projects
Commit 3ae70ab1 authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Check if username is valid and remove slashes from filename

parent 1e20067c
No related branches found
No related tags found
No related merge requests found
......@@ -246,11 +246,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)) {
$file = str_replace(array('/', '\\'), '', $file);
// Then copy the folder over
OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment