Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1075
diff -u -p -r1.1075 user.module
--- modules/user/user.module	1 Nov 2009 21:26:44 -0000	1.1075
+++ modules/user/user.module	7 Nov 2009 04:25:14 -0000
@@ -385,6 +385,7 @@ function user_save($account, $edit = arr
     // Do not allow 'uid' to be changed.
     $edit['uid'] = $account->uid;
     // Save changes to the user table.
+    $edit['mail'] = trim($edit['mail']);
     $success = drupal_write_record('users', $edit, 'uid');
     if ($success === FALSE) {
       // The query failed - better to abort the save than risk further
@@ -556,7 +557,6 @@ function user_validate_name($name) {
 }
 
 function user_validate_mail($mail) {
-  $mail = trim($mail);
   if (!$mail) {
     return t('You must enter an e-mail address.');
   }
@@ -1018,6 +1018,7 @@ function user_account_form_validate($for
     }
 
     // Validate the e-mail address, and check if it is taken by an existing user.
+    $form_state['values']['mail'] = trim($form_state['values']['mail']);
     if ($error = user_validate_mail($form_state['values']['mail'])) {
       form_set_error('mail', $error);
     }
