summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-06 15:24:56 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-04-02 10:21:33 +0200
commit39e2297210d9d2938c75fc911d45f0e863dc4821 (patch)
tree0fec68f7a688c827ecde281ea9fd44610c1dd331 /tests/utils_tests
parent00c68f03b5dc6c14618026347ee0da4d466c88e3 (diff)
Fixed CVE-2025-27556 -- Mitigated potential DoS in url_has_allowed_host_and_scheme() on Windows.
Thank you sw0rd1ight for the report.
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_http.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index 3730c2fcf5..95ec2fc516 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -7,6 +7,7 @@ from django.test import SimpleTestCase
from django.utils.datastructures import MultiValueDict
from django.utils.http import (
MAX_HEADER_LENGTH,
+ MAX_URL_LENGTH,
base36_to_int,
content_disposition_header,
escape_leading_slashes,
@@ -274,6 +275,21 @@ class URLHasAllowedHostAndSchemeTests(unittest.TestCase):
False,
)
+ def test_max_url_length(self):
+ allowed_host = "example.com"
+ max_extra_characters = "é" * (MAX_URL_LENGTH - len(allowed_host) - 1)
+ max_length_boundary_url = f"{allowed_host}/{max_extra_characters}"
+ cases = [
+ (max_length_boundary_url, True),
+ (max_length_boundary_url + "ú", False),
+ ]
+ for url, expected in cases:
+ with self.subTest(url=url):
+ self.assertIs(
+ url_has_allowed_host_and_scheme(url, allowed_hosts={allowed_host}),
+ expected,
+ )
+
class URLSafeBase64Tests(unittest.TestCase):
def test_roundtrip(self):