Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-16919 - Convert uppercase to lowercase for param_username and upd…

…ating test result in testmoodlelib.
  • Loading branch information...
commit 34d2b19a15cade07c3893ef83896e9219dfbda9b 1 parent 1edad60
Rossiani Wijaya authored
Showing with 7 additions and 8 deletions.
  1. +3 −4 lib/moodlelib.php
  2. +4 −4 lib/simpletest/testmoodlelib.php
7 lib/moodlelib.php
View
@@ -745,13 +745,12 @@ function clean_param($param, $type) {
case PARAM_USERNAME:
$param = str_replace(" " , "", $param);
- if (empty($CFG->extendedusernamechars)) {
+ $param = moodle_strtolower($param); // Convert uppercase to lowercase MDL-16919
+ if (empty($CFG->extendedusernamechars)) {
// regular expression, eliminate all chars EXCEPT:
// alphanum, dash (-), underscore (_), at sign (@) and period (.) characters.
$param = preg_replace('/[^-\.@_a-z0-9]/', '', $param);
- } else {
- $param = preg_replace('/[A-Z]/', '', $param);
- }
+ }
return $param;
default: // throw error, switched parameters in optional_param or another serious problem
8 lib/simpletest/testmoodlelib.php
View
@@ -310,8 +310,8 @@ function test_clean_param() {
$this->assertEqual(clean_param('john~doe', PARAM_USERNAME), 'johndoe');
$this->assertEqual(clean_param('john´doe', PARAM_USERNAME), 'johndoe');
$this->assertEqual(clean_param('john#$%&() ', PARAM_USERNAME), 'john');
- $this->assertEqual(clean_param('JOHNdóé ', PARAM_USERNAME), 'd');
- $this->assertEqual(clean_param('john.,:;-_/|\ñÑ[]A_X-,D {} ~!@#$%^&*()_+ ?><[] ščřžžý ?ýáž?žý??šdoe ', PARAM_USERNAME), 'john.-__-@_doe');
+ $this->assertEqual(clean_param('JOHNdóé ', PARAM_USERNAME), 'johnd');
+ $this->assertEqual(clean_param('john.,:;-_/|\ñÑ[]A_X-,D {} ~!@#$%^&*()_+ ?><[] ščřžžý ?ýáž?žý??šdoe ', PARAM_USERNAME), 'john.-_a_x-d@_doe');
// Test success condition, if extendedusernamechars == ENABLE;
@@ -320,8 +320,8 @@ function test_clean_param() {
$this->assertEqual(clean_param('john@doe', PARAM_USERNAME), 'john@doe');
$this->assertEqual(clean_param('john# $%&()+_^', PARAM_USERNAME), 'john#$%&()+_^');
$this->assertEqual(clean_param('john~doe', PARAM_USERNAME), 'john~doe');
- $this->assertEqual(clean_param('joHN´doe', PARAM_USERNAME), 'jo´doe');
- $this->assertEqual(clean_param('johnDOE', PARAM_USERNAME), 'john');
+ $this->assertEqual(clean_param('joHN´doe', PARAM_USERNAME), 'john´doe');
+ $this->assertEqual(clean_param('johnDOE', PARAM_USERNAME), 'johndoe');
$this->assertEqual(clean_param('johndóé ', PARAM_USERNAME), 'johndóé');
$CFG->extendedusernamechars = $currentstatus;
Please sign in to comment.
Something went wrong with that request. Please try again.