I came across a possible inconsistency in the regex for domain name validation in django/core/validators.py
- it appears to be different in the URLValidator
and the EmailValidator
.
In the EmailValidator
it looks like the regex doesn’t account for internationalised domain names with non-ASCII characters.
Should this be consistent in both the validators? How should we be handling the internationalised domain names?
This is related to the current ticket I’m looking at on adding a DomainNameValidator. I think the logic there should be something like:
if accept_idna:
domain_name = punycode(domain_name) # i.e. convert to ASCII characters
# accept a string that is just ASCII (and whatever other constraints there are for a domain name)
else:
# just accept a domain name that's ASCII
But would be grateful for views/advice.