[Django] #30924: Numbers in top-level domain raise ValidationError

4 views
Skip to first unread message

Django

unread,
Oct 28, 2019, 4:49:18 PM10/28/19
to django-...@googlegroups.com
#30924: Numbers in top-level domain raise ValidationError
-----------------------------------------+------------------------
Reporter: fosterseth | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The current {{{regex}}} in
[https://github.com/django/django/blob/54ea290e5bbd19d87bd8dba807738eeeaf01a362/django/core/validators.py#L75
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}'}}}

https://github.com/ansible/awx/issues/5081

--
Ticket URL: <https://code.djangoproject.com/ticket/30924>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 29, 2019, 3:37:32 AM10/29/19
to django-...@googlegroups.com
#30924: Numbers in top-level domain raise ValidationError
-----------------------------+--------------------------------------
Reporter: fosterseth | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* type: Bug => New feature
* version: 2.2 => master
* component: Uncategorized => Forms
* resolution: => wontfix


Comment:

I'm going to suggest that creating a `URLField` subclass with an altered
`URLValidator` is precisely the way to go here. I think the vast majority
of users are **not** encountering TLDs including numbers.

Since this would be a design change, please though follow-up on the
DevelopersMailingList to discuss more fully. If there's consensus for a
change there, then we could re-open as a New Feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/30924#comment:1>

Reply all
Reply to author
Forward
0 new messages