summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorPierre Quentel <pierre.quentel@gmail.com>2019-09-11 11:05:53 (GMT)
committerBenjamin Peterson <benjamin@python.org>2019-09-11 11:05:53 (GMT)
commit2d7cacacc310b65b43e7e2de89e7722291dea6a4 (patch)
tree97f6f93239ec1c04a28cb05b713f24cc951caafc /Lib/cgi.py
parent972cf5c06a5ba16ad243a442dbb9c15307fbed95 (diff)
downloadcpython-2d7cacacc310b65b43e7e2de89e7722291dea6a4.zip
cpython-2d7cacacc310b65b43e7e2de89e7722291dea6a4.tar.gz
cpython-2d7cacacc310b65b43e7e2de89e7722291dea6a4.tar.bz2
bpo-20504 : in cgi.py, fix bug when a multipart/form-data request has… (#10638)
* bpo-20504 : in cgi.py, fix bug when a multipart/form-data request has no content-length header * Add Misc/NEWS.d/next file. * Add rst formatting for NEWS.d/next file * Reaplce assert by self.assertEqual
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index b96bd1f..c22c71b 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -461,7 +461,7 @@ class FieldStorage:
if maxlen and clen > maxlen:
raise ValueError('Maximum content length exceeded')
self.length = clen
- if self.limit is None and clen:
+ if self.limit is None and clen >= 0:
self.limit = clen
self.list = self.file = None
@@ -642,8 +642,10 @@ class FieldStorage:
if 'content-length' in headers:
del headers['content-length']
+ limit = None if self.limit is None \
+ else self.limit - self.bytes_read
part = klass(self.fp, headers, ib, environ, keep_blank_values,
- strict_parsing,self.limit-self.bytes_read,
+ strict_parsing, limit,
self.encoding, self.errors, max_num_fields)
if max_num_fields is not None:
@@ -734,7 +736,7 @@ class FieldStorage:
last_line_lfend = True
_read = 0
while 1:
- if _read >= self.limit:
+ if self.limit is not None and _read >= self.limit:
break
line = self.fp.readline(1<<16) # bytes
self.bytes_read += len(line)