diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-09-11 12:22:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-11 12:22:38 (GMT) |
commit | 99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab (patch) | |
tree | cbd2af3a8c43d816e08d4a73db35e2e64e763b15 /Lib/cgi.py | |
parent | 0553369b9827bb5497bb7a65f64dd259781ae792 (diff) | |
download | cpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.zip cpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.tar.gz cpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.tar.bz2 |
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 2d7cacacc310b65b43e7e2de89e7722291dea6a4)
Co-authored-by: Pierre Quentel <pierre.quentel@gmail.com>
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-x | Lib/cgi.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -478,7 +478,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 @@ -659,8 +659,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: @@ -751,7 +753,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) |