This is a minor bug, but probably one that should get resolved for consistency.
In Ubercart, when we have an anonymous checkout, we create a username based off of the email address. Unfortunately in this process we do not check to see if that generated username contains characters Drupal considers invalid. This could create issues in the future, but currently, we're able to login with a generated username which contains invalid characters.
To resolve this we check check the username against function user_validate_name($name) in user.module. We should trim out the characters from the email which it considers are invalid and generate the username based off that. The function which generates the username is function uc_store_email_to_username($mail)
Maybe more work than it's worth, but I figure I'd bring it up.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 475226.email_replacement.1.x.patch | 558 bytes | cha0s |
| #9 | email_replacement.patch | 494 bytes | Island Usurper |
| #8 | ubercart-475226-8.patch | 529 bytes | cedarm |
| #7 | ubercart-475226-7.patch | 1.15 KB | cedarm |
Comments
Comment #1
j0rd commentedoh. Invalid email example would be a special gMail one like:
myemail+spamtag@gmail.com
Drupal doesn't allow the '+'
Comment #2
rszrama commentedIssue sounds worth fixing to me; is there an API function we can use to strip out illegitimate characters?
Comment #3
cha0s commentedNot that I can see. I was planning on repurposing the validate function for this purpose. Unless I'm blind and missed it. :)
Comment #4
rszrama commentedWhy don't we just reduce the username to alphanumeric characters to begin with? There's no real need to preserve periods in the usernames, and that's all I can imagine someone would have in their e-mail addy. I don't think hyphens or underscores are allowed. I'm sure alphanumeric names will pass validation. : )
Comment #5
rszrama commentedComment #6
cedarm commentedComment #7
cedarm commentedCode copied from the user_import module's _user_import_sanitise_username().
Comment #8
cedarm commentedOn second thought, this patch may be more appropriate since we're starting with an email address.
Comment #9
Island Usurper commentedI don't think
[:alnum:]works in preg_replace(). I've only seen it in MySQL regular expressions.(Oh, it also works in ereg_replace(). Interesting.)
Here's an equivalent expression in PCRE syntax.
Comment #10
rszrama commentedWorked for me. Thanks everyone!
Comment #11
rszrama commentedComment #12
cha0s commentedYarrr, the old 3-liner
Comment #13
rszrama commentedYou be da man. Yarr.