Hello,

Judging from the (rather confused) discussion on the users lists, it looks like 
we’re discussing in the abstract. No one has tested whether the problem can 
happen with Django.

Since the ticket quoted below says Django (unexpectedly) accepts non-ascii 
usernames on Python 3, it’s just a matter of trying to create a user called 
rené and one called rené.

Here’s how to create these strings if copy-pasting them doesn’t suffice:

>>> composed = 'rené'
>>> composed.encode('utf-8')
b'ren\xc3\xa9'
>>> import unicodedata
>>> decomposed = unicodedata.normalize('NFKD', composed)
>>> decomposed.encode('utf-8')
b'rene\xcc\x81’

I suspect the problem may not exist on full-featured database (i.e. not 
SQLite), depending on the database’s collation settings, which will cause these 
two strings to compare identical on most reasonable setups.

Who wants to try on various databases?

If it turns out that the problem does exist and that Django should normalize 
things, it should normalize to NFKC. Proposing normalization to NFKD suggests a 
lack of familiarity with the topic.

For what it’s worth, I’m in favor of restoring the intended behavior of 
restricting usernames to ASCII on Python 3 and letting developers who want 
something more elaborate implement their own requirements.

One last anecdote: I live in a country where many people have non-ASCII names 
and no one would ask for a non-ASCII username because everyone knows it would 
cause problems at some point, even if IT thinks otherwise! :-)

-- 
Aymeric.

> On 21 Apr 2016, at 20:16, Rick Leir <[email protected]> wrote:
> 
> Thanks. To summarize quickly, (corrections please)
> 
> 2008 - Usernames in django.contrib.auth are restricted to ASCII  
> alphanumerics. Allowing Unicode seems fairly simple: compile the  
> validator's regular expression with the re.UNICODE flag.
> 
> but:
> http://en.wikipedia.org/wiki/Internationalized_domain_name#ASCII_Spoofing_and_squatting_concerns
> 
> 2014 - trac issue still open, no tests, no patches, with problems in 
> difference between py2 and py3 (py2 is supported until 2017)
> 
> normalization could be done with 
> https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
> unicodedata.normalize(input, 'NFKD')
> 
> 
> On Thursday, 21 April 2016 11:43:56 UTC-4, Tim Graham wrote:
> Here is one: 
> https://groups.google.com/d/topic/django-developers/6aAHgP5g0lA/discussion 
> <https://groups.google.com/d/topic/django-developers/6aAHgP5g0lA/discussion>
> (all I did was search "unicode username")
> 
> Here's a relevant Trac ticket: https://code.djangoproject.com/ticket/21379 
> <https://code.djangoproject.com/ticket/21379>
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/django-developers 
> <https://groups.google.com/group/django-developers>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/746795c5-7009-48c4-8065-9d5c1997033c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/746795c5-7009-48c4-8065-9d5c1997033c%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2D6A86D6-C907-4D1E-8CF4-43289B8B278F%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to