+ character not stripped from email address

bob_hirnlego - March 14, 2009 - 15:48
Project:Email Registration
Version:6.x-1.1
Component:Miscellaneous
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

If I register with an address like bob.hirnlego+drupal@gmail.com, the plus character is not stripped.
I think it should as Drupal allows only dots, dashes and underscores, if I'm not mistaken.

#1

scottgifford - April 4, 2009 - 21:29
Status:active» needs review

I'm having the same problem. Here is a patch against 5.x-1.3 that works for me. It change any non-word characters (anything besides letters, numbers, and underscores) to an underscore.

Sorry, I don't have a Drupal 6 installation to test with, but the change is very simple.

AttachmentSize
email_registration_username_funnychars.patch 662 bytes

#2

twistor - April 5, 2009 - 12:44

I tested that on Drupal 6 and it indeed works but this may be a little more proper.

AttachmentSize
email_registration-username_funny_chars-2.patch 706 bytes

#3

greggles - June 10, 2009 - 12:25

Rather than building our own, what about basing this on http://api.drupal.org/api/function/user_validate_name ?

#4

scottgifford - June 10, 2009 - 14:10

@greggles, that function will just report whether the username is valid, and won't fix it. If we are auto-generating the username from an email address, and the user portion of the email address contains characters that aren't legal in a Drupal username, we can't simply tell the user we don't accept their email address.

But you're right that we could probably use some of the patterns from that code to detect and replace illegal characters. I'd be happy to put together a patch that does that if it would help get this applied.

#5

greggles - June 10, 2009 - 14:27

Yes, I didn't expect we would literally use that function, but that it could be helpful to base the replacements used in email_registration on the code in it.

If you update your patch to base it on that code, I'd be willing to apply it. If you created some simpletests for it - #485778: simpletests for email registration - I would be really happy to apply it ;)

#6

josepvalls - October 5, 2009 - 13:55

Just a note. I read the post title and I want to notify that the + character is a somewhat valid e-mail character.
I use gmail and I love when I can use things like:
myusername+something@gmail.com
myusername+important@gmail.com
myusername+garbage@gmail.com

 
 

Drupal is a registered trademark of Dries Buytaert.