diff options
author | Nils Philippsen <nils@redhat.com> | 2015-08-19 16:23:10 +0200 |
---|---|---|
committer | Nils Philippsen <nils@redhat.com> | 2015-08-19 16:23:10 +0200 |
commit | a5ee861c01ec94096dea918d551be596f844291e (patch) | |
tree | 2bee7bc9c75409feaa2c84db2ca13213d7902fd7 /paste/request.py | |
parent | 0a70450e3f57e6478b9244f42aeebea744fec77c (diff) | |
download | paste-a5ee861c01ec94096dea918d551be596f844291e.tar.gz |
Python 3: Don't mangle strangely encoded input
In Python 3, cgi.FieldStorage needs to know about encodings like
shiftjis in order to decode it properly (in Python 2 it's simply not
decoded at all).
Fixes tests.test_wsgiwrappers.test_wsgirequest_charset
Diffstat (limited to 'paste/request.py')
-rw-r--r-- | paste/request.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/paste/request.py b/paste/request.py index f0d91c1..8d5e5c3 100644 --- a/paste/request.py +++ b/paste/request.py @@ -140,7 +140,7 @@ def parse_dict_querystring(environ): environ['paste.parsed_dict_querystring'] = (multi, source) return multi -def parse_formvars(environ, include_get_vars=True): +def parse_formvars(environ, include_get_vars=True, encoding=None, errors=None): """Parses the request, returning a MultiDict of form variables. If ``include_get_vars`` is true then GET (query string) variables @@ -182,9 +182,16 @@ def parse_formvars(environ, include_get_vars=True): environ['CONTENT_TYPE'] = '' else: input = environ['wsgi.input'] + kwparms = {} + if six.PY3: + if encoding: + kwparms['encoding'] = encoding + if errors: + kwparms['errors'] = errors fs = cgi.FieldStorage(fp=input, environ=environ, - keep_blank_values=1) + keep_blank_values=1, + **kwparms) environ['QUERY_STRING'] = old_query_string if fake_out_cgi: environ['CONTENT_TYPE'] = old_content_type |