summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cgi.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-08-18 17:23:48 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-08-18 17:23:48 (GMT)
commit7a0eadc6d5aea200e4b24c658b9a07ed30ee7452 (patch)
tree4725e5500eff2a7ca763caf14726d6a969a2cd5f /Lib/test/test_cgi.py
parent501b4a73980d363fca3a69d5999d377f3ae5cc3f (diff)
parent1e26dc7ef60c19f57e779bb1f7906e446d71d343 (diff)
downloadcpython-7a0eadc6d5aea200e4b24c658b9a07ed30ee7452.zip
cpython-7a0eadc6d5aea200e4b24c658b9a07ed30ee7452.tar.gz
cpython-7a0eadc6d5aea200e4b24c658b9a07ed30ee7452.tar.bz2
(Merge 3.5) cgi.FieldStorage.read_multi ignores Content-Length
Issue #24764: cgi.FieldStorage.read_multi() now ignores the Content-Length header in part headers. Patch written by Peter Landry and reviewed by Pierre Quentel.
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r--Lib/test/test_cgi.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index a7a9d02..ab9f6ab 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -326,6 +326,24 @@ Content-Type: text/plain
got = getattr(files[x], k)
self.assertEqual(got, exp)
+ def test_fieldstorage_part_content_length(self):
+ BOUNDARY = "JfISa01"
+ POSTDATA = """--JfISa01
+Content-Disposition: form-data; name="submit-name"
+Content-Length: 5
+
+Larry
+--JfISa01"""
+ env = {
+ 'REQUEST_METHOD': 'POST',
+ 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
+ 'CONTENT_LENGTH': str(len(POSTDATA))}
+ fp = BytesIO(POSTDATA.encode('latin-1'))
+ fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1")
+ self.assertEqual(len(fs.list), 1)
+ self.assertEqual(fs.list[0].name, 'submit-name')
+ self.assertEqual(fs.list[0].value, 'Larry')
+
def test_fieldstorage_as_context_manager(self):
fp = BytesIO(b'x' * 10)
env = {'REQUEST_METHOD': 'PUT'}