#12989: URLValidator's verify_exists fails on IDN (Internationalized Domain 
Names)
---------------------------+------------------------------------------------
 Reporter:  frasern        |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.1       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 Changeset [12474] introduced validation for IDN values in URLs. However,
 the `verify_exists=True` functionality doesn't work when you try to verify
 an IDN exists...

 {{{
 >>> from django.core.validators import URLValidator
 >>> url = u'http://עברית.idn.icann.org'
 >>> URLValidator(url)
 True
 >>> URLValidator(url, verify_exists=True)
 ValidationError
 }}}

 The problem seems to be that `urllib2` doesn't support IDN directly:

 {{{
 >>> req = urllib2.Request(url)
 >>> urllib2.urlopen(req)
 UnicodeEncodeError...
 }}}

 This can be resolved if the IDNA-encoded version is used instead:

 {{{
 idna_url = 'http://xn--54b7fta0cc.idn.icann.org/'
 >>> req = urllib2.Request(idna_url)
 >>> urllib2.urlopen(req)
 <addinfourl at 3082877196L whose fp = <socket._fileobject object at
 0xb7c1333c>>
 }}}

 ICANN has a [http://idn.icann.org/#The_example.test_names|list of example
 names] which might be useful for testing.

 See also discussion at http://groups.google.com/group/django-
 developers/browse_frm/thread/6403db0c5229700a

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12989>
Django <http://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to