Skip to content

Commit

Permalink
Fix application of _decode_key and _decode_value in WSGIGateway_u0. F…
Browse files Browse the repository at this point in the history
…ixes test and fixes #1350.
  • Loading branch information
jaraco committed Sep 28, 2016
1 parent 6e8775a commit 6efc7ac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cherrypy/wsgiserver/__init__.py
Expand Up @@ -2497,7 +2497,7 @@ def get_environ(self):
"""Return a new environ dict targeting the given wsgi.version"""
req = self.req
env_10 = WSGIGateway_10.get_environ(self)
env = dict(map(self._decode_key, self.items()))
env = dict(map(self._decode_key, env_10.items()))
env[six.u('wsgi.version')] = ('u', 0)

# Request-URI
Expand All @@ -2511,18 +2511,20 @@ def get_environ(self):
env['PATH_INFO'] = env_10['PATH_INFO']
env['QUERY_STRING'] = env_10['QUERY_STRING']

env.update(map(self._decode_value, self.items()))
env.update(map(self._decode_value, env.items()))

return env

@staticmethod
def _decode_key(k, v):
def _decode_key(item):
k, v = item
if six.PY2:
k = k.decode('ISO-8859-1')
return k, v

@staticmethod
def _decode_value(k, v):
def _decode_value(item):
k, v = item
skip_keys = 'REQUEST_URI', 'wsgi.input'
if six.PY3 or not isinstance(v, bytes) or k in skip_keys:
return k, v
Expand Down

0 comments on commit 6efc7ac

Please sign in to comment.