Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/wsgicgi.py @ 50777:04bfcb416745 stable
hgweb: pass strings in WSGI environment correctly from wsgicgi
According to PEP 3333, the strings in the WSGI environment must be translatable
to bytes using the ISO-8859-1 codec.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Fri, 08 Sep 2023 15:33:03 +0200 |
parents | f254fc73d956 |
children | 32c13716147e |
line wrap: on
line diff
--- a/mercurial/hgweb/wsgicgi.py Wed Sep 06 18:11:12 2023 +0200 +++ b/mercurial/hgweb/wsgicgi.py Fri Sep 08 15:33:03 2023 +0200 @@ -9,10 +9,8 @@ # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side -import os - from ..pycompat import getattr -from .. import pycompat +from .. import encoding, pycompat from ..utils import procutil @@ -23,7 +21,10 @@ procutil.setbinary(procutil.stdin) procutil.setbinary(procutil.stdout) - environ = dict(os.environ.items()) # re-exports + environ = { + k.decode('iso8859-1'): v.decode('iso8859-1') + for k, v in encoding.environ.items() + } # re-exports environ.setdefault('PATH_INFO', '') if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'): # IIS includes script_name in PATH_INFO