News for hackers. Stuff that matters.
Re:Let’s talk about usernames by jcranmer on Monday February 12, 2018 @12:17AM (#16356708)
To emphasize your point: don't touch email addresses. You can get away with doing equality checks on NFKC case folding, but don't assume that you can store a lowercased email address and have it work properly.

Lots of weird email systems exist. Don't assume that everybody works like gmail. And do test that things work right with uppercase letters in email addresses: I've been locked out of systems before because I use an uppercase letter in my email address and one half of the system was trying to match the lower cased version to the actual text.

Re:Let’s talk about usernames by inopinatus on Monday February 12, 2018 @01:50AM (#16357008)
The local part (left of the @) of email addresses is case sensitive by definition and this should not be controversial.

RFC5321 s2.4:

   The local-part of a mailbox MUST BE treated as case sensitive.
   Therefore, SMTP implementations MUST take care to preserve the case
   of mailbox local-parts.  In particular, for some hosts, the user
   "smith" is different from the user "Smith".
Even though it goes on to say:

   However, exploiting the case sensitivity of mailbox local-parts impedes
   interoperability and is discouraged.
This doesn't prohibit a local delivery agent (such as Gmail) consolidating multiple variants into one mailbox, but everything up until that point must refrain from making assumptions.
Re:Let’s talk about usernames by craigds on Monday February 12, 2018 @02:46AM (#16357182)
That's definitely controversial, and in my experience, just plain wrong. Many, many users sign up to a service with [email protected] and get confused when they later try to log in with [email protected]. we had to add a fix for this in our django user model a couple years back. We havent had any complaints with the new, case insensitive system. IMHO this sort of this should be upstreamed but it seems Django have decided to stick with the spec in spite of usability.
Re:Let’s talk about usernames by jcranmer on Monday February 12, 2018 @09:19AM (#16358674)
As you clarify later, both case-sensitive and case-insensitive are wrong. What you generally want is case-preserving: store the original case, but allow case-insensitive matches to select it.
Re:Let’s talk about usernames by chatmasta on Monday February 12, 2018 @03:57AM (#16357432)
This is an especially common problem when entering email addresses on mobile. Often autocorrect will capitalize the first letter. I always make sure it’s lowercase when registering, but I can see how this could easily lead to confusion.
Re:Let’s talk about usernames by lsaferite on Monday February 12, 2018 @01:40PM (#16360799)
Web pages (and apps) that don't indicate the input box is actually an email address so auto-correct won't capitalize for you are a serious peev of mine.
Re:Let’s talk about usernames by craigds on Monday February 12, 2018 @02:52AM (#16357199)
Oh also, we used a CITEXT field for storing email addresses. Store the case the user registers with, and use that for sending comms etc, but uniquify and match (on login etc) in a case insensitive way.
Re:Let’s talk about usernames by pluma on Monday February 12, 2018 @04:20AM (#16357508)
I ran into this problem as well and in the end added a separate field for the normalized (lowercase) form with a uniqueness check on that. Users would still be presented the original case and it would be preserved when sending e-mails but for identification/uniqueness purposes e-mails were considered case insensitive.
Re:Let’s talk about usernames by papito on Saturday February 17, 2018 @08:10AM (#16400516)
Right, something like "email_lc", and "username_lc". This would be your unique index.
Re:Let’s talk about usernames by ubernostrum on Monday February 12, 2018 @12:47AM (#16356805)
Unfortunately, Gmail rules the world and has trained people to expect that they can be sloppy and inconsistent and enter their email address as 'johndoe' or 'john.doe' or 'JohnDoe' or 'John.Doe'... etc. and it just works, I don't understand why your site is broken, because my email works!

And when that happens, trying to patiently pull a "well, technically" and explain to them about RFC this and the specs say that is a way to lose users.

(I actually have extremely strong feelings about email, email addresses and the whole associated mess of specs, but had to tone it down for this article since it was mostly about the various traps you can wander into from naïvely thinking that you can just read a spec or implement something obvious and get away with it)

Re:Let’s talk about usernames by kqr on Monday February 12, 2018 @01:07AM (#16356883)
> And when that happens, trying to patiently pull a "well, technically" and explain to them about RFC this and the specs say that is a way to lose users.

Not in my experience. Showing compassion and agreeing with them that what happened is terrible and you wish things were different but you didn't call these shots back in the days and if they want improvement you can both go together and complain to google, the service which is actually broken.

Most people just want to be listened to. If you can do that, you'll earn a loyal fan, even if you don't do exactly what they tell you to when agitated. Some will even appreciate learning more about the email systems after the fact. They may even get the feeling you went above and beyond by offering to help them with matters outside of your site.

Re:Let’s talk about usernames by ubernostrum on Monday February 12, 2018 @01:47AM (#16356996)
Most people just want to be listened to.

Many people, even after being listened to, and even after having things patiently explained to them, still continue to enter someone else's email address into forms which will send sensitive information to that email address, and complain that they never got their important email, or that some "hacker" has "hacked" "their" email, etc.

In a perfect world this would not happen. We don't live in a perfect world and are unlikely to live in a perfect world any time soon, so we should not be asking "how can we be pedantic and tell users it's their fault for not reading the RFCs", we should be asking "how can we protect users from their ignorance of the RFCs".

(when I wrote this article, I did not expect that this would be the single most controversial line in it from HN's perspective, but I guess by this point I should have anticipated it)

Re:Let’s talk about usernames by jorams on Monday February 12, 2018 @02:22AM (#16357095)
> has trained people to expect that they can be sloppy and inconsistent and enter their email address as 'johndoe' or 'john.doe'

Has it? In my experience, even if people know dots and the part after the + don't matter for their Gmail account (and most don't) they know it doesn't matter to Gmail, a peculiarity they can use to create multiple accounts on a single website without creating new email accounts.

(This is different from case insensitivity, which the majority of popular email providers seem to implement.)

Re:Let’s talk about usernames by spc476 on Monday February 12, 2018 @03:16AM (#16357271)
And I constantly get email for other people with my name at gmail.com. Let's see ... I'm married, and I have a few girlfriends, I run marathons, and I've been to several family reunions. Oh, and I'm in the process of buying several different cars. Wheeee!
Re:Let’s talk about usernames by ajdlinux on Monday February 12, 2018 @01:15AM (#16356899)
I suppose the tradeoff here is when you get two non-Gmail users, johndoe and john.doe, who are legitimately different people, one of whom gets very confused and is actually unable to use their correct address.

On the one hand, that's a (presumably extremely) rare corner case - on the other hand, some applications must handle those corner cases.

Re:Let’s talk about usernames by spc476 on Monday February 12, 2018 @03:17AM (#16357277)
Re:Let’s talk about usernames by kbenson on Monday February 12, 2018 @02:48AM (#16357188)
People where trained for that long before Gmail even existed. Email systems have generally followed Postel's law, since it makes life easier for all parties.

Do you want to run a support system where when you ask for people's username or email address, you also have to ask them for their casing (and in the case that their problem is that they didn't know it mattered, they may not know what they signed up for)?

I worked at an ISP for many years. Even though it was all backed by Linux, usernames (which included email addresses) were considered case insensitive for the purpose of the service (all usernames were lowercase). It solves so many problems and the downsides are so small all the sane email providers did it.

The flip side of this is that it was a simpler time. Usernames and email addresses were ASCII, not Unicode. These days with Unicode, you can't even be sure that uppercasing and then lowercasing an already lowercased string yields the same characters.

Re:Let’s talk about usernames by neltnerb on Monday February 12, 2018 @01:51AM (#16357011)
Oh, I assumed the recommendation was to store the actual email address as entered, and then also generate the fingerprint to compare for similarity. Wouldn't you just keep both?
Re:Let’s talk about usernames by mhandley on Monday February 12, 2018 @05:33AM (#16357791)
The problem is that [email protected] and [email protected] can be different people, or [email protected] and [email protected]. On gmail, they can't, but on my university email system for example, this is the default naming convension for circa 50,000 people. If you consider them to be the same, one of them can't sign up to your service. How often this happens? Probably not all that often. But if you run a popular service, it will bite a few people.