Allowing numbers in the top level domain

64 views
Skip to first unread message

s b f

unread,
Oct 29, 2019, 4:32:50 PM10/29/19
to Django developers (Contributions to Django itself)
https://code.djangoproject.com/ticket/30924#ticket

The current regex in ​URLValidator does not allow numbers in the top-level domain

e.g. www.example.org33 raises a ValidationError

Rarely, if ever, do public top-level domains contain a number, however internal, private networks can certainly be configured with numbers present in the top-level domain. Thus it is important to handle these URIs without having to specify custom regex patterns to pass into the URLValidator.

The change can be achieved by replacing the following line in the URLValidator class:
r'(?:[a-z' + ul + '-]{2,63}'

with

r'(?:[a-z' + ul + r'0-9' + '-]{2,63}'

I think the same rationale for allowing dashes in the top level domain (https://code.djangoproject.com/ticket/25452#comment:2) can be argued for this case

To note, the above line change would allow for addresses like

to pass, which are currently in invalid_urls.txt

I am hoping this post generates some meaningful discussion around this proposed design change, thanks!


Claude Paroz

unread,
Oct 30, 2019, 3:40:40 AM10/30/19
to Django developers (Contributions to Django itself)
Hi,

Could you please tell us a bit more about what the specs say about numbers in the top-level domain?

Claude

Aymeric Augustin

unread,
Oct 30, 2019, 6:49:53 AM10/30/19
to django-d...@googlegroups.com
Hello,

Also, as far as I know, the URLValidator is intended to catch common mistakes of people typing URLs in text fields rather than to enforce strictly a standard.

Best regards,

-- 
Aymeric.

--
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 django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/e2587b66-b398-4b74-a17a-a4dbb4bdec29%40googlegroups.com.


--
Aymeric.
Reply all
Reply to author
Forward
0 new messages