--- email_registration.module~	2008-02-17 01:02:28.000000000 +0000
+++ email_registration.module	2009-04-04 21:23:22.000000000 +0000
@@ -10,6 +10,8 @@
   switch ($op) {
     case 'insert':
     $namenew = preg_replace('/@.*$/', '', $edit['mail']);
+    // Change any non-word characters to underscores
+    $namenew = preg_replace('/\W/', '_', $namenew);
     // if username generated from email record already exists, append underscore and number eg:(chris_123)
     if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $account->uid, $namenew)) > 0) {
       // find the next number available to append to the name
