[Django] #26244: URLValidator and http/request.py use different validators

7 views
Skip to first unread message

Django

unread,
Feb 19, 2016, 12:07:31 PM2/19/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------+--------------------
Reporter: zachborboa | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
The host validation patterns should probably be the same and written in a
way that allows their reuse.

~
https://github.com/django/django/blob/master/django/core/validators.py#L99
~ https://github.com/django/django/blob/master/django/http/request.py#L25

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

Django

unread,
Feb 19, 2016, 12:16:08 PM2/19/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------------+-------------------------------------
Reporter: zachborboa | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
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
-------------------------------------+-------------------------------------
Changes (by timgraham):

* component: Uncategorized => HTTP handling
* needs_better_patch: => 0
* type: Uncategorized => Cleanup/optimization
* needs_tests: => 0
* needs_docs: => 0


Comment:

Unless there is some problem that fixing this will solve, I vote not to
try to combine the two. `URLValidator` changes too often. If we cause some
regression there, at least it's some limited compared to if we also break
`django.http.request`.

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

Django

unread,
Feb 19, 2016, 12:44:15 PM2/19/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------------+-------------------------------------
Reporter: zachborboa | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
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 zachborboa):

`host_validation_re` could be changed from

{{{#!python
host_validation_re =
re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")
}}}

to something like
{{{#!python
host_validation_re = re.compile(
r'(?:' + ipv4_re + '|' + ipv6_re + '|' + host_re + ')'
r'(?::\d{2,5})?' # port
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26244#comment:2>

Django

unread,
Feb 19, 2016, 3:04:00 PM2/19/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------------+-------------------------------------
Reporter: zachborboa | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
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
-------------------------------------+-------------------------------------
Changes (by timgraham):

* cc: apollo13 (added)


Comment:

Florian, what do you think? The regular expression in `request.py` is a
security fix from 27560924ec1e567be4727ef8d7dfc4d3879c048c.

--
Ticket URL: <https://code.djangoproject.com/ticket/26244#comment:3>

Django

unread,
Feb 21, 2016, 11:51:10 AM2/21/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------------+-------------------------------------
Reporter: zachborboa | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
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 apollo13):

I do not see big wins in changing it and am worried that it becomes a
nightmare like we have with host_re. Simple & easy is preferable in those
code paths imo.

--
Ticket URL: <https://code.djangoproject.com/ticket/26244#comment:4>

Django

unread,
Feb 22, 2016, 7:41:03 AM2/22/16
to django-...@googlegroups.com
#26244: URLValidator and http/request.py use different validators
-------------------------------------+-------------------------------------
Reporter: zachborboa | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: HTTP handling | 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 timgraham):

* status: new => closed
* resolution: => wontfix


Comment:

Thanks, sounds like we're in agreement then.

--
Ticket URL: <https://code.djangoproject.com/ticket/26244#comment:5>

Reply all
Reply to author
Forward
0 new messages