mirror of
https://github.com/python/cpython.git
synced 2025-08-08 19:09:46 +00:00
bpo-20504 : in cgi.py, fix bug when a multipart/form-data request has… (GH-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
(cherry picked from commit 2d7cacacc3
)
Co-authored-by: Pierre Quentel <pierre.quentel@gmail.com>
This commit is contained in:
parent
f3e430b079
commit
e3bd941e4e
3 changed files with 24 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue