Opened 8 years ago

Last modified 8 years ago

#27125 closed New feature

Can not support django Internationalized domain name in URLValidation — at Version 2

Reported by: Ramin Farajpour Cami Owned by: nobody
Component: Core (URLs) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramin Farajpour Cami)

Hi,

i see here validator.py, there isn't docs aboud IDN supported django IDN or no,

there is arabic domains on internet like عربي.امارات

from django.core.validators import URLValidator
validate = URLValidator()

validate('http://عربی.امارات')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django\core\validators.py", line 114, in __call__
    value = force_text(value)
  File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 88, in force_text
    raise DjangoUnicodeDecodeError(s, *e.args)
django.utils.encoding.DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0x9f in position 12: invalid start byte. You passed in 'http://\xe3\xa9\xa0?.\x9f\xea\x9f\xa9\x9f\xa2' (<type 'str'>)

You can use idn2 tool.

root@ramin ~ > idn2 'عربي.امارات'
xn--ngbrx4e.xn--mgbaam7a8h
root@ramin > nslookup $(idn2 'عربي.امارات')
Server:         127.0.1.1
Address:        127.0.1.1#53

Non-authoritative answer:
Name:   xn--ngbrx4e.xn--mgbaam7a8h
Address: 79.98.120.105

root@ramin > nmap $(idn2 'عربي.امارات') -p80

Starting Nmap 6.40 ( http://nmap.org ) at 2016-08-26 12:09 +07
Nmap scan report for xn--ngbrx4e.xn--mgbaam7a8h (79.98.120.105)
Host is up (0.23s latency).
rDNS record for 79.98.120.105: web-lb0.web.308th.dubai.aeda.net.ae
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.88 seconds  

or use CURL

$ curl --head xn--ngbrx4e.xn--mgbaam7a8h

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.0 200 OK
Date: Fri, 26 Aug 2016 05:09:07 GMT
Server: Apache
X-Powered-By: PHP/5.3.3
Content-Type: text/html
Connection: close


please see this answer stackoverflow

Thanks,
Ramin

Change History (2)

comment:1 by Ramin Farajpour Cami, 8 years ago

Component: UncategorizedCore (URLs)

comment:2 by Ramin Farajpour Cami, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top