#17386: Validation & Unicode Character 'ZERO WIDTH SPACE' (U+200B) -------------------------------+-------------------------------------- Reporter: pennersr | Owner: nobody Type: Uncategorized | Status: new Component: Forms | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+--------------------------------------
Comment (by aaugustin): Per [http://tools.ietf.org/html/rfc3696#section-2 RFC 3696], email addresses can use non-ASCII characters: > Any characters, or combination of bits (as octets), are permitted in DNS names. Names will be encoded with IDNA when an ASCII representation is required. The `EmailValidator` takes this into account: {{{ class EmailValidator(RegexValidator): def __call__(self, value): try: super(EmailValidator, self).__call__(value) except ValidationError, e: # Trivial case failed. Try for possible IDN domain-part if value and u'@' in value: parts = value.split(u'@') try: parts[-1] = parts[-1].encode('idna') except UnicodeError: raise e super(EmailValidator, self).__call__(u'@'.join(parts)) else: raise }}} However, `\u200b` encodes to nothing with IDNA: {{{ >>> u'-\u200b-'.encode('idna') == '--' True >>> len(u'-\u200b-'.encode('idna')) 2 }}} I spent some time fighting with various online encoders and couldn't confirm or infirm whether this is a valid result. Anyway, that's the reason why the email address is valid, after IDNA encoding of the domain part. -- Ticket URL: <https://code.djangoproject.com/ticket/17386#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.