http.request does not support ipv6-formatted ipv4 addresses

Bug #1611923 reported by LaMont Jones
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Django
Unknown
Unknown
python-django (Ubuntu)
Fix Released
Medium
Jon Grimm
Xenial
Won't Fix
Medium
Jon Grimm

Bug Description

SRU Template

[Impact]

  * django-python is unable to use ipv6 formatted ipv4 addresses.
For example, Addresses of the form "::ffff:169.254.169.254" are perfectly valid, but not supported. This package is a dependency of maas and openstack among others, thus will limit deployments.

  * The upstream fix is available, simple, and provides an updated testcase to cover and regress-test.

[Test Case]

 * The updated unit test case is probably the simplest way to verify.
 * See tests/README.rst: Updated test case will fail without the accompanied fix.

 $ PYTHONPATH=..:$PYTHONPATH ./runtests.py requests
 Testing against Django installed in '/home/jgrimm/work/sru/django-python/python-django-1.8.7/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...........................................
----------------------------------------------------------------------
 PYTHONPATH=..:$PYTHONPATH ./runtests.py requests
Testing against Django installed in '/home/jgrimm/work/sru/django-python/python-django-1.8.7/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...........................................
----------------------------------------------------------------------
Ran 43 tests in 0.016s
OK

[Regression Potential]

 * Low potential for regression as validation regex becomes more permissive.
 * Full unit test additionally run to ensure no new failures.

[Other Info]

 * Backported from upstream with no modifications required.

-- original bug description --

Addresses of the form "::ffff:169.254.169.254" are perfectly valid, but not supported by django's http.request.

The following diff addresses the problem.

--- django/http/request.py 2015-11-24 10:21:15.000000000 -0700
+++ django/http/request.py.new 2016-08-10 13:12:17.459998895 -0600
@@ -23,7 +23,7 @@
 )

 RAISE_ERROR = object()
-host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")
+host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9\.:]+\])(:\d+)?$")

 class UnreadablePostError(IOError):

Luke Faraone (lfaraone)
tags: added: patch
Changed in python-django (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Robie Basak (racb)
tags: added: bitesize
Revision history for this message
Luke Faraone (lfaraone) wrote :
Robie Basak (racb)
Changed in python-django (Ubuntu):
assignee: nobody → Jon Grimm (jgrimm)
Revision history for this message
Jon Grimm (jgrimm) wrote :

Lamont, do you need this fixed back on Xenial or elsewhere? or sufficient in Yakkety?

I've built and run the requests unit tests successfully, just want to do a bit more testing and then I'll seek sponsor for Yakkety.

Changed in python-django (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Jon Grimm (jgrimm) wrote :

OK. Looks fine. Attaching debdiff.

Revision history for this message
Jon Grimm (jgrimm) wrote :

Fixed LP comment in changelog.

Revision history for this message
Jon Grimm (jgrimm) wrote :

Quick IRC chat with Lamont. Not a hard requirement for him personally, but we've discussed its probably the right thing to do SRU into Xenial at least for others.

Revision history for this message
Nish Aravamudan (nacc) wrote :

Thanks Jon, I'll prepare the uploads shortly!

Revision history for this message
Jon Grimm (jgrimm) wrote :

FWIW, uploaded, just waiting on beta freeze before it can migrate.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-django - 1.8.7-1ubuntu7

---------------
python-django (1.8.7-1ubuntu7) yakkety; urgency=medium

  * Backport upstream fix for ipv6-formatted ipv4 addresses (LP: #1611923)

 -- Jon Grimm <email address hidden> Thu, 15 Sep 2016 23:14:29 -0500

Changed in python-django (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Jon Grimm (jgrimm) wrote :

[Impact]

  * django-python is unable to use ipv6 formatted ipv4 addresses. This package is a dependency of maas and openstack among others, thus will limit deployments.

  * The upstream fix is available, simple, and provides an updated testcase to cover and regress-test.

[Test Case]

 * The updated unit test case is probably the simplest way to verify.
 * See tests/README.rst: Updated test case will fail without the accompanied fix.

 $ PYTHONPATH=..:$PYTHONPATH ./runtests.py requests
 Testing against Django installed in '/home/jgrimm/work/sru/django-python/python-django-1.8.7/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...........................................
----------------------------------------------------------------------
 PYTHONPATH=..:$PYTHONPATH ./runtests.py requests
Testing against Django installed in '/home/jgrimm/work/sru/django-python/python-django-1.8.7/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...........................................
----------------------------------------------------------------------
Ran 43 tests in 0.016s
OK

[Regression Potential]

 * Low potential for regression as host regex becomes more permissive.
 * Full unit test additionally run to ensure no new failures.

[Other Info]

 * Backported from upstream with no modifications required.

Jon Grimm (jgrimm)
description: updated
Changed in python-django (Ubuntu Xenial):
importance: Undecided → Low
importance: Low → Medium
Revision history for this message
Jon Grimm (jgrimm) wrote :
Jon Grimm (jgrimm)
Changed in python-django (Ubuntu Xenial):
status: New → Triaged
assignee: nobody → Jon Grimm (jgrimm)
description: updated
Revision history for this message
Jon Grimm (jgrimm) wrote :
Jon Grimm (jgrimm)
Changed in python-django (Ubuntu Xenial):
status: Triaged → In Progress
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello LaMont, or anyone else affected,

Accepted python-django into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-django/1.8.7-1ubuntu5.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-django (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Bryce Harrington (bryce) wrote :

It looks like this fix did not go out in xenial due to the verification not being performed:
  https://launchpad.net/ubuntu/+source/python-django/1.8.7-1ubuntu5.4

Xenial reached its end of standard support, so if this fix is still desired it should be pursued under extended support.

Changed in python-django (Ubuntu Xenial):
status: Fix Committed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.