Index: uc_store/uc_store.module
===================================================================
--- uc_store/uc_store.module	(revision 1015)
+++ uc_store/uc_store.module	(working copy)
@@ -1651,6 +1651,23 @@
   // Default to the first part of the e-mail address.
   $name = substr($email, 0, strpos($email, '@'));
 
+  // Username cannot contain an illegal character.
+  $name = preg_replace('/[^\x80-\xF7 [:alnum:]@_.-]/', '', $name);
+  $name = preg_replace(
+    '/[\x{80}-\x{A0}'.        // Non-printable ISO-8859-1 + NBSP
+    '\x{AD}'.                 // Soft-hyphen
+    '\x{2000}-\x{200F}'.      // Various space characters
+    '\x{2028}-\x{202F}'.      // Bidirectional text overrides
+    '\x{205F}-\x{206F}'.      // Various text hinting characters
+    '\x{FEFF}'.               // Byte order mark
+    '\x{FF01}-\x{FF60}'.      // Full-width latin
+    '\x{FFF9}-\x{FFFD}'.      // Replacement characters
+    '\x{0}]/u',
+    '', $name);
+  
+  // Username cannot contain multiple spaces in a row.
+  $name = preg_replace('/[ ]+/', ' ', $name);
+
   // Trim that value for spaces and length.
   $name = trim(substr($name, 0, USERNAME_MAX_LENGTH - 4));
 
