Skip to content

Commit

Permalink
MDL-27884 Implement proper username validation during csv import
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Jan 2, 2013
1 parent d63a406 commit 363ed37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion admin/tool/uploaduser/index.php
Expand Up @@ -285,7 +285,11 @@
$userserrors++; $userserrors++;
continue; continue;
} }

if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {
$upt->track('status', get_string('invalidusername', 'error', 'username'), 'error');
$upt->track('username', $errorstr, 'error');
$userserrors++;
}
if ($existinguser = $DB->get_record('user', array('username'=>$user->username, 'mnethostid'=>$CFG->mnet_localhost_id))) { if ($existinguser = $DB->get_record('user', array('username'=>$user->username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
$upt->track('id', $existinguser->id, 'normal', false); $upt->track('id', $existinguser->id, 'normal', false);
} }
Expand Down
1 change: 1 addition & 0 deletions lang/en/error.php
Expand Up @@ -331,6 +331,7 @@
$string['invaliduser'] = 'Invalid user'; $string['invaliduser'] = 'Invalid user';
$string['invaliduserid'] = 'Invalid user id'; $string['invaliduserid'] = 'Invalid user id';
$string['invaliduserfield'] = 'Invalid user field: {$a}'; $string['invaliduserfield'] = 'Invalid user field: {$a}';
$string['invalidusername'] = 'The given username contains invalid characters';
$string['invalidxmlfile'] = '"{$a}" is not a valid XML file'; $string['invalidxmlfile'] = '"{$a}" is not a valid XML file';
$string['iplookupfailed'] = 'Cannot find geo information about this IP address {$a}'; $string['iplookupfailed'] = 'Cannot find geo information about this IP address {$a}';
$string['iplookupprivate'] = 'Cannot display lookup of private IP address'; $string['iplookupprivate'] = 'Cannot display lookup of private IP address';
Expand Down

0 comments on commit 363ed37

Please sign in to comment.