summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-05-14 22:11:55 (GMT)
committerNed Deily <nad@python.org>2018-05-14 22:11:55 (GMT)
commit545c955be997efd6b3827b981024e6b9945d82d1 (patch)
tree7e66dc411f94029250b67465c474dfde19695cde /Lib/cgi.py
parent3059042410dce69806b94be72d5c8055d616f3a3 (diff)
downloadcpython-545c955be997efd6b3827b981024e6b9945d82d1.zip
cpython-545c955be997efd6b3827b981024e6b9945d82d1.tar.gz
cpython-545c955be997efd6b3827b981024e6b9945d82d1.tar.bz2
bpo-33497: Add errors param to cgi.parse_multipart and make an encoding in FieldStorage use the given errors (GH-6804)
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index f5e85aa..f82cc6c 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -198,13 +198,14 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
DeprecationWarning, 2)
return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
-def parse_multipart(fp, pdict, encoding="utf-8"):
+def parse_multipart(fp, pdict, encoding="utf-8", errors="replace"):
"""Parse multipart input.
Arguments:
fp : input file
pdict: dictionary containing other parameters of content-type header
- encoding: request encoding
+ encoding, errors: request encoding and error handler, passed to
+ FieldStorage
Returns a dictionary just like parse_qs(): keys are the field names, each
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"):
headers = Message()
headers.set_type(ctype)
headers['Content-Length'] = pdict['CONTENT-LENGTH']
- fs = FieldStorage(fp, headers=headers, encoding=encoding,
+ fs = FieldStorage(fp, headers=headers, encoding=encoding, errors=errors,
environ={'REQUEST_METHOD': 'POST'})
return {k: fs.getlist(k) for k in fs}
@@ -458,7 +459,8 @@ class FieldStorage:
self.type = ctype
self.type_options = pdict
if 'boundary' in pdict:
- self.innerboundary = pdict['boundary'].encode(self.encoding)
+ self.innerboundary = pdict['boundary'].encode(self.encoding,
+ self.errors)
else:
self.innerboundary = b""