summaryrefslogtreecommitdiff
path: root/tests/requests_tests
diff options
context:
space:
mode:
authorsammiee5311 <sammiee5311@gmail.com>2026-02-16 12:21:03 +0900
committerJacob Walls <jacobtylerwalls@gmail.com>2026-02-24 13:44:42 -0500
commite84dc8715e91d51364ba6bda2b2fb07e7a8b750e (patch)
tree60b14a481d6a4745a71354ae5fe0206ee7757f0f /tests/requests_tests
parentacd0bec51366e259b4c2b43e4c09755541cdf560 (diff)
Fixed #36931 -- Handled LookupError in multipart parser for invalid RFC 2231 encoding.
Added LookupError to the except clause so invalid headers are silently skipped, consistent with other malformed header handling.
Diffstat (limited to 'tests/requests_tests')
-rw-r--r--tests/requests_tests/tests.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/requests_tests/tests.py b/tests/requests_tests/tests.py
index e52989b0da..e1744bf180 100644
--- a/tests/requests_tests/tests.py
+++ b/tests/requests_tests/tests.py
@@ -455,11 +455,18 @@ class RequestsTests(SimpleTestCase):
request.body
def test_malformed_multipart_header(self):
- for header in [
- 'Content-Disposition : form-data; name="name"',
- 'Content-Disposition:form-data; name="name"',
- 'Content-Disposition :form-data; name="name"',
- ]:
+ tests = [
+ ('Content-Disposition : form-data; name="name"', {"name": ["value"]}),
+ ('Content-Disposition:form-data; name="name"', {"name": ["value"]}),
+ ('Content-Disposition :form-data; name="name"', {"name": ["value"]}),
+ # The invalid encoding causes the entire part to be skipped.
+ (
+ 'Content-Disposition: form-data; name="name"; '
+ "filename*=BOGUS''test%20file.txt",
+ {},
+ ),
+ ]
+ for header, expected_post in tests:
with self.subTest(header):
payload = FakePayload(
"\r\n".join(
@@ -480,7 +487,7 @@ class RequestsTests(SimpleTestCase):
"wsgi.input": payload,
}
)
- self.assertEqual(request.POST, {"name": ["value"]})
+ self.assertEqual(request.POST, expected_post)
def test_body_after_POST_multipart_related(self):
"""