[Django] #32298: django.core.validators.URLValidator tests netloc instead of hostname for length

2 views
Skip to first unread message

Django

unread,
Dec 24, 2020, 8:13:59 AM12/24/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-----------------------------------------+------------------------
Reporter: zt_initech | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
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 |
-----------------------------------------+------------------------
This code:
https://github.com/django/django/blob/master/django/core/validators.py#L141

urlparse:
https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse

In case of url like
{{{
urlparse('https://username1:pass...@example.com/foo')
}}}

the parse result is:
{{{
ParseResult(scheme='https', netloc='username1:pass...@example.com',
path='/foo', params='', query='', fragment='')
}}}

with the username and password in netloc.

Of course if the netloc is too long only because of the password, this
causes a valid URL to be not accepted.

The test for length is a requirement for the hostname, so it should test
.hostname instead of .netloc

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

Django

unread,
Dec 26, 2020, 5:15:29 AM12/26/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
--------------------------------------+------------------------------------
Reporter: zt_initech | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Claude Paroz):

* type: Uncategorized => Cleanup/optimization
* version: 3.1 => master
* component: Uncategorized => Core (Other)
* easy: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Dec 26, 2020, 9:40:41 AM12/26/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned

Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Akshat Dixit):

* owner: nobody => Akshat Dixit
* status: new => assigned


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

Django

unread,
Dec 26, 2020, 10:33:22 AM12/26/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Akshat Dixit):

* has_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

https://github.com/django/django/pull/13811

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

Django

unread,
Dec 26, 2020, 10:42:33 AM12/26/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Ready for checkin => Accepted


Comment:

This ticket is not ready for checkin (see
[https://docs.djangoproject.com/en/3.1/internals/contributing/triaging-
tickets/#triage-stages Triage stages]). Also you shouldn't mark your own
patches as ready for checkin.

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

Django

unread,
Dec 26, 2020, 10:50:02 AM12/26/20
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Akshat Dixit):

Replying to [comment:4 Mariusz Felisiak]:


> This ticket is not ready for checkin (see
[https://docs.djangoproject.com/en/3.1/internals/contributing/triaging-
tickets/#triage-stages Triage stages]). Also you shouldn't mark your own
patches as ready for checkin.

I am sorry, I did not understand the terminology correctly. Thankyou for
your correction.

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

Django

unread,
Jan 2, 2021, 9:46:58 AM1/2/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Akshat Dixit):

Hello, Can someone help me in progressing this patch. I have submitted a
patch which has passed all the build tests. I will also like to write
tests for this bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:6>

Django

unread,
Jan 2, 2021, 2:11:39 PM1/2/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

The next step is to write a test, you may need to explore a bit the
`tests` folder of Django to find out where other URL validation tests are
located.

--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:7>

Django

unread,
Jan 3, 2021, 1:09:13 AM1/3/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Akshat Dixit):

Added test of this case to
{{{
tests/validators/tests.py
}}}
where all other url validation tests are present and committed changes to
same pull request. https://github.com/django/django/pull/13811.

--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:8>

Django

unread,
Jan 3, 2021, 1:37:03 PM1/3/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Akshat Dixit):

* needs_tests: 1 => 0


Comment:

Tests and patch availabe at
> https://github.com/django/django/pull/13811

--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:9>

Django

unread,
Jan 4, 2021, 2:34:59 AM1/4/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:10>

Django

unread,
Jan 4, 2021, 3:45:22 AM1/4/21
to django-...@googlegroups.com
#32298: django.core.validators.URLValidator tests netloc instead of hostname for
length
-------------------------------------+-------------------------------------
Reporter: zt_initech | Owner: Akshat
Type: | Dixit
Cleanup/optimization | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b41d38ae26b1da9519a6cd765bc2f2ce7d355007" b41d38a]:
{{{
#!CommitTicketReference repository=""
revision="b41d38ae26b1da9519a6cd765bc2f2ce7d355007"
Fixed #32298 -- Fixed URLValidator hostname length validation.

URLValidator now validates the maximum length of a hostname without
the userinfo and port.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32298#comment:11>

Reply all
Reply to author
Forward
0 new messages