bpo-33497: Add errors param to cgi.parse_multipart and make an encodi… · python/cpython@e8f968d (original) (raw)
`@@ -198,13 +198,14 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
`
198
198
`DeprecationWarning, 2)
`
199
199
`return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
`
200
200
``
201
``
`-
def parse_multipart(fp, pdict, encoding="utf-8"):
`
``
201
`+
def parse_multipart(fp, pdict, encoding="utf-8", errors="replace"):
`
202
202
`"""Parse multipart input.
`
203
203
``
204
204
` Arguments:
`
205
205
` fp : input file
`
206
206
` pdict: dictionary containing other parameters of content-type header
`
207
``
`-
encoding: request encoding
`
``
207
`+
encoding, errors: request encoding and error handler, passed to
`
``
208
`+
FieldStorage
`
208
209
``
209
210
` Returns a dictionary just like parse_qs(): keys are the field names, each
`
210
211
` value is a list of values for that field. For non-file fields, the value
`
`@@ -217,7 +218,7 @@ def parse_multipart(fp, pdict, encoding="utf-8"):
`
217
218
`headers = Message()
`
218
219
`headers.set_type(ctype)
`
219
220
`headers['Content-Length'] = pdict['CONTENT-LENGTH']
`
220
``
`-
fs = FieldStorage(fp, headers=headers, encoding=encoding,
`
``
221
`+
fs = FieldStorage(fp, headers=headers, encoding=encoding, errors=errors,
`
221
222
`environ={'REQUEST_METHOD': 'POST'})
`
222
223
`return {k: fs.getlist(k) for k in fs}
`
223
224
``
`@@ -458,7 +459,8 @@ def init(self, fp=None, headers=None, outerboundary=b'',
`
458
459
`self.type = ctype
`
459
460
`self.type_options = pdict
`
460
461
`if 'boundary' in pdict:
`
461
``
`-
self.innerboundary = pdict['boundary'].encode(self.encoding)
`
``
462
`+
self.innerboundary = pdict['boundary'].encode(self.encoding,
`
``
463
`+
self.errors)
`
462
464
`else:
`
463
465
`self.innerboundary = b""
`
464
466
``