@@ -198,13 +198,14 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
198198 DeprecationWarning , 2 )
199199 return urllib .parse .parse_qsl (qs , keep_blank_values , strict_parsing )
200200
201- def parse_multipart (fp , pdict , encoding = "utf-8" ):
201+ def parse_multipart (fp , pdict , encoding = "utf-8" , errors = "replace" ):
202202 """Parse multipart input.
203203
204204 Arguments:
205205 fp : input file
206206 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
208209
209210 Returns a dictionary just like parse_qs(): keys are the field names, each
210211 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"):
217218 headers = Message ()
218219 headers .set_type (ctype )
219220 headers ['Content-Length' ] = pdict ['CONTENT-LENGTH' ]
220- fs = FieldStorage (fp , headers = headers , encoding = encoding ,
221+ fs = FieldStorage (fp , headers = headers , encoding = encoding , errors = errors ,
221222 environ = {'REQUEST_METHOD' : 'POST' })
222223 return {k : fs .getlist (k ) for k in fs }
223224
@@ -458,7 +459,8 @@ def __init__(self, fp=None, headers=None, outerboundary=b'',
458459 self .type = ctype
459460 self .type_options = pdict
460461 if 'boundary' in pdict :
461- self .innerboundary = pdict ['boundary' ].encode (self .encoding )
462+ self .innerboundary = pdict ['boundary' ].encode (self .encoding ,
463+ self .errors )
462464 else :
463465 self .innerboundary = b""
464466
0 commit comments