summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-08-11 10:41:10 -0400
committerTim Graham <timograham@gmail.com>2016-08-11 13:54:39 -0400
commitff0a5aff4f5eb2f55fa4c45d316084ee4d462d6d (patch)
tree21f2cbc6efa7f35d2d73a28d32f4bc4783250024
parent4c2a6fe75bad592972eafc79debc35bf944f38f7 (diff)
downloaddjango-ff0a5aff4f5eb2f55fa4c45d316084ee4d462d6d.tar.gz
Fixed #27046 -- Supported IPv6-formatted IPv4 addresses in host validation.
Thanks LaMont Jones for the report and patch.
-rw-r--r--django/http/request.py2
-rw-r--r--tests/requests/tests.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 1dedf5d899..271ab30557 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -24,7 +24,7 @@ from django.utils.six.moves.urllib.parse import (
)
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):
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index b015e6dfff..0465f0a1e8 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -589,7 +589,7 @@ class HostValidationTests(SimpleTestCase):
ALLOWED_HOSTS=[
'forward.com', 'example.com', 'internal.com', '12.34.56.78',
'[2001:19f0:feee::dead:beef:cafe]', 'xn--4ca9at.com',
- '.multitenant.com', 'INSENSITIVE.com',
+ '.multitenant.com', 'INSENSITIVE.com', '[::ffff:169.254.169.254]',
])
def test_http_get_host(self):
# Check if X_FORWARDED_HOST is provided.
@@ -641,6 +641,7 @@ class HostValidationTests(SimpleTestCase):
'insensitive.com',
'example.com.',
'example.com.:80',
+ '[::ffff:169.254.169.254]',
]
for host in legit_hosts: