diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-17 13:34:41 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-17 13:34:41 (GMT) |
commit | c7bfe0e42eb72d941a8a131e870aefabd4547015 (patch) | |
tree | 25472c68db5275339492a7a52a0a59a2b8d1c01a /Lib/test/test_cgi.py | |
parent | 8b5629207944516a18834aec32e314b4aa4c09b2 (diff) | |
download | cpython-c7bfe0e42eb72d941a8a131e870aefabd4547015.zip cpython-c7bfe0e42eb72d941a8a131e870aefabd4547015.tar.gz cpython-c7bfe0e42eb72d941a8a131e870aefabd4547015.tar.bz2 |
Issue #18167: cgi.FieldStorage no more fails to handle multipart/form-data
when \r\n appears at end of 65535 bytes without other newlines.
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r-- | Lib/test/test_cgi.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index cb28aa8..0a1e8d3 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -256,6 +256,29 @@ class CgiTests(unittest.TestCase): got = getattr(fs.list[x], k) self.assertEqual(got, exp) + def test_fieldstorage_multipart_maxline(self): + # Issue #18167 + maxline = 1 << 16 + self.maxDiff = None + def check(content): + data = """---123 +Content-Disposition: form-data; name="upload"; filename="fake.txt" +Content-Type: text/plain + +%s +---123-- +""".replace('\n', '\r\n') % content + environ = { + 'CONTENT_LENGTH': str(len(data)), + 'CONTENT_TYPE': 'multipart/form-data; boundary=-123', + 'REQUEST_METHOD': 'POST', + } + self.assertEqual(gen_result(data, environ), + {'upload': content.encode('latin1')}) + check('x' * (maxline - 1)) + check('x' * (maxline - 1) + '\r') + check('x' * (maxline - 1) + '\r' + 'y' * (maxline - 1)) + _qs_result = { 'key1': 'value1', 'key2': ['value2x', 'value2y'], |