summaryrefslogtreecommitdiff
path: root/tests/file_uploads
diff options
context:
space:
mode:
authorRaul Cumplido <raulcumplido@gmail.com>2015-01-24 12:14:30 +0000
committerClaude Paroz <claude@2xlibre.net>2015-01-27 20:12:22 +0100
commitac650d02cbb66ab652ae529b8f03b486ef974dfb (patch)
tree652d2c933dae539bbe1261d4451900832c64b3fa /tests/file_uploads
parent332139d23dc79cdc846e8e51f0eeee7ddbc9d568 (diff)
Fixed #24209 -- Prevented crash when parsing malformed RFC 2231 headers
Thanks Tom Christie for the report and review.
Diffstat (limited to 'tests/file_uploads')
-rw-r--r--tests/file_uploads/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index 34681122e4..610cf13630 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -584,3 +584,20 @@ class MultiParserTests(unittest.TestCase):
for raw_line, expected_title in test_data:
parsed = parse_header(raw_line)
self.assertEqual(parsed[1]['title'], expected_title)
+
+ def test_rfc2231_wrong_title(self):
+ """
+ Test wrongly formatted RFC 2231 headers (missing double single quotes).
+ Parsing should not crash (#24209).
+ """
+ test_data = (
+ (b"Content-Type: application/x-stuff; title*='This%20is%20%2A%2A%2Afun%2A%2A%2A",
+ b"'This%20is%20%2A%2A%2Afun%2A%2A%2A"),
+ (b"Content-Type: application/x-stuff; title*='foo.html",
+ b"'foo.html"),
+ (b"Content-Type: application/x-stuff; title*=bar.html",
+ b"bar.html"),
+ )
+ for raw_line, expected_title in test_data:
+ parsed = parse_header(raw_line)
+ self.assertEqual(parsed[1]['title'], expected_title)