MDL-10498 fixed handling of username and emails with single quotes

This commit is contained in:
skodak
2009-09-27 19:13:22 +00:00
parent 582d4d91a0
commit 6ab0935e93
2 changed files with 6 additions and 5 deletions
+3 -3
View File
@@ -118,18 +118,18 @@ class user_edit_form extends moodleform {
// validate email
if (!isset($usernew->email)) {
// mail not confirmed yet
} else if (!validate_email($usernew->email)) {
} else if (!validate_email(stripslashes($usernew->email))) {
$errors['email'] = get_string('invalidemail');
} else if ((stripslashes($usernew->email) !== $user->email) and record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$errors['email'] = get_string('emailexists');
}
if (isset($usernew->email) and $usernew->email === $user->email and over_bounce_threshold($user)) {
if (isset($usernew->email) and stripslashes($usernew->email) === $user->email and over_bounce_threshold($user)) {
$errors['email'] = get_string('toomanybounces');
}
if (isset($usernew->email) and !empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) {
$errorstr = email_is_not_allowed($usernew->email);
$errorstr = email_is_not_allowed(stripslashes($usernew->email));
if ($errorstr !== false) {
$errors['email'] = $errorstr;
}
+3 -2
View File
@@ -132,13 +132,14 @@ class user_editadvanced_form extends moodleform {
if (empty($usernew->username)) {
//might be only whitespace
$err['username'] = get_string('required');
} else if (!$user or $user->username !== $usernew->username) {
} else if (!$user or $user->username !== stripslashes($usernew->username)) {
//check new username does not exist
if (record_exists('user', 'username', $usernew->username, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['username'] = get_string('usernameexists');
}
//check allowed characters
if ($usernew->username !== moodle_strtolower($usernew->username)) {
echo 'grrrr';
$err['username'] = get_string('usernamelowercase');
} else {
if (empty($CFG->extendedusernamechars)) {
@@ -151,7 +152,7 @@ class user_editadvanced_form extends moodleform {
}
if (!$user or $user->email !== stripslashes($usernew->email)) {
if (!validate_email($usernew->email)) {
if (!validate_email(stripslashes($usernew->email))) {
$err['email'] = get_string('invalidemail');
} else if (record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['email'] = get_string('emailexists');