diff --git a/core/includes/form.inc b/core/includes/form.inc index ae319a8..08a6349 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3764,8 +3764,11 @@ function theme_email($variables) { * Note that #maxlength and #required is validated by _form_validate() already. */ function form_validate_email(&$element, &$form_state) { - if ($element['#value'] !== '' && !valid_email_address($element['#value'])) { - form_error($element, t('The e-mail address %mail is not valid.', array('%mail' => $element['#value']))); + $value = trim($element['#value']); + form_set_value($element, $value, $form_state); + + if ($value !== '' && !valid_email_address($value)) { + form_error($element, t('The e-mail address %mail is not valid.', array('%mail' => $value))); } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 84987ec..54199ee 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -393,9 +393,6 @@ function user_save($account, $edit = array()) { // Avoid overwriting an existing password with a blank password. unset($edit['pass']); } - if (isset($edit['mail'])) { - $edit['mail'] = trim($edit['mail']); - } // Load the stored entity, if any. if (!empty($account->uid) && !isset($account->original)) { @@ -1127,7 +1124,7 @@ function user_account_form_validate($form, &$form_state) { // Trim whitespace from mail, to prevent confusing 'e-mail not valid' // warnings often caused by cutting and pasting. - $mail = trim($form_state['values']['mail']); + $mail = $form_state['values']['mail']; if ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($mail), 'LIKE')->range(0, 1)->execute()->fetchField()) { // Format error message dependent on whether the user is logged in or not.