Refs #33697 -- Fixed multipart parsing of headers with double quotes and semicolons.
See 1ef0c0349e
This commit is contained in:
parent
295249c901
commit
93cedc82f2
|
@ -748,7 +748,7 @@ def _parse_header_params(s):
|
|||
while s[:1] == b";":
|
||||
s = s[1:]
|
||||
end = s.find(b";")
|
||||
while end > 0 and s.count(b'"', 0, end) % 2:
|
||||
while end > 0 and (s.count(b'"', 0, end) - s.count(b'\\"', 0, end)) % 2:
|
||||
end = s.find(b";", end + 1)
|
||||
if end < 0:
|
||||
end = len(s)
|
||||
|
|
|
@ -944,3 +944,9 @@ class MultiParserTests(SimpleTestCase):
|
|||
for raw_line, expected_title in test_data:
|
||||
parsed = parse_header(raw_line)
|
||||
self.assertEqual(parsed[1]["title"], expected_title)
|
||||
|
||||
def test_parse_header_with_double_quotes_and_semicolon(self):
|
||||
self.assertEqual(
|
||||
parse_header(b'form-data; name="files"; filename="fo\\"o;bar"'),
|
||||
("form-data", {"name": b"files", "filename": b'fo"o;bar'}),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue