Merge pull request #2236 from owncloud/fix-migration

Check if username is valid and remove slashes from filename
This commit is contained in:
Bernhard Posselt 2013-03-11 08:43:09 -07:00
commit 769317702f
1 changed files with 9 additions and 0 deletions

View File

@ -246,11 +246,20 @@ class OC_Migrate{
OC_Log::write( 'migration', 'User doesn\'t exist', OC_Log::ERROR ); OC_Log::write( 'migration', 'User doesn\'t exist', OC_Log::ERROR );
return json_encode( array( 'success' => false ) ); 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 // Copy data
$userfolder = $extractpath . $json->exporteduser; $userfolder = $extractpath . $json->exporteduser;
$newuserfolder = $datadir . '/' . self::$uid; $newuserfolder = $datadir . '/' . self::$uid;
foreach(scandir($userfolder) as $file){ 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 // Then copy the folder over
OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file); OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file);
} }