On Thu, 2014-02-27 at 20:11 -0800, schinckel wrote:

> But there's the rub. Whilst for _most_ email servers, this will indeed
> send mail to the same account, there's nowhere that says this _must_
> happen.

I agree. Reading RFC 822, it says
        
        The  domain-dependent
        string is uninterpreted, except by the final sub-domain; the rest
        of the mail service merely transmits it as a literal string.

and

        The local-part of an  addr-spec  in  a  mailbox  specification
        (i.e.,  the  host's  name for the mailbox) is understood to be
        whatever the receiving mail protocol server allows.

So normalize_email() already does the right thing by normalising the
domain part, and leaving the local part alone. It is my understanding
that normalising the local part (by e.g. lowercasing) is never the right
thing.

There are three possible situations:

1. Receiving MTA does not care about case: Users can enter whatever form
they like, and expect to receive their mail. No problem with
normalisation in Django, although it might be good to preserve the
user's preferred form. User@... and user@... are actually the same
address on the MTA, so enforcing uniqueness with iexact lookup is no
problem, and acutally necessary to catch all variants the user might
enter on login.

2. Receiving MTA does care about case: Django must preserve case in
local part if we care about such users receiving email from us. We can
trust the users of such a MTA to enter the right case. Enforcing
uniqueness across case is not necessary, but not a problem either
unless...

3. ... there are actually distinct accounts with User@... and user@...
(and USER@... etc.) on that MTA, and more than one such user tries to
register with a Django app.

There is no way to support all three, and I think case 1. is by far the
most common, followed by 2., and I am willing to bet that 3. does not
happen in the wild.

My preferred solution would be to leave normalize_email() as is, and to
enforce case insensitive uniqueness by whatever means Django and/or the
DBMS offers.

Kind regards, Til


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/1393580930.9673.20.camel%40mother.subnetz.org.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to