Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-27884 Implement proper username validation during csv import

  • Loading branch information...
commit 2e505a05d13f3835da9d37e8d75d0843f0cc16c7 1 parent 10ad21d
Ankit Agarwal ankitagarwal authored

Showing 2 changed files with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 1 admin/tool/uploaduser/index.php
  2. +1 0  lang/en/error.php
6 admin/tool/uploaduser/index.php
@@ -285,7 +285,11 @@
285 285 $userserrors++;
286 286 continue;
287 287 }
288   -
  288 + if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {
  289 + $upt->track('status', get_string('invalidusername', 'error', 'username'), 'error');
  290 + $upt->track('username', $errorstr, 'error');
  291 + $userserrors++;
  292 + }
289 293 if ($existinguser = $DB->get_record('user', array('username'=>$user->username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
290 294 $upt->track('id', $existinguser->id, 'normal', false);
291 295 }
1  lang/en/error.php
@@ -329,6 +329,7 @@
329 329 $string['invaliduser'] = 'Invalid user';
330 330 $string['invaliduserid'] = 'Invalid user id';
331 331 $string['invaliduserfield'] = 'Invalid user field: {$a}';
  332 +$string['invalidusername'] = 'The given username contains invalid characters';
332 333 $string['invalidxmlfile'] = '"{$a}" is not a valid XML file';
333 334 $string['iplookupfailed'] = 'Cannot find geo information about this IP address {$a}';
334 335 $string['iplookupprivate'] = 'Cannot display lookup of private IP address';

0 comments on commit 2e505a0

Please sign in to comment.
Something went wrong with that request. Please try again.