##// END OF EJS Templates
hgweb: pass strings in WSGI environment correctly from wsgicgi...
Manuel Jacob -
r51830:04bfcb41 stable
parent child Browse files
Show More
@@ -0,0 +1,18 b''
1 $ hg init test
2 $ cat >hgweb.cgi <<HGWEB
3 > #!$PYTHON
4 > from mercurial import demandimport; demandimport.enable()
5 > from mercurial.hgweb import hgweb
6 > from mercurial.hgweb import wsgicgi
7 > application = hgweb(b"test", b"Empty test repository")
8 > wsgicgi.launch(application)
9 > HGWEB
10 $ chmod 755 hgweb.cgi
11
12 Check that non-ASCII bytes roundtrip correctly.
13
14 $ . "$TESTDIR/cgienv"
15 $ PATH_INFO="/rev/$(python -c 'import sys; sys.stdout.buffer.write(b"\xe2\x80\x94")')"; export PATH_INFO
16 $ QUERY_STRING="style=raw"; export QUERY_STRING
17 $ "$PYTHON" ./hgweb.cgi | grep error
18 error: unknown revision '\xe2\x80\x94' (esc)
@@ -9,10 +9,8 b''
9 # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
9 # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
10
10
11
11
12 import os
13
14 from ..pycompat import getattr
12 from ..pycompat import getattr
15 from .. import pycompat
13 from .. import encoding, pycompat
16
14
17 from ..utils import procutil
15 from ..utils import procutil
18
16
@@ -23,7 +21,10 b' def launch(application):'
23 procutil.setbinary(procutil.stdin)
21 procutil.setbinary(procutil.stdin)
24 procutil.setbinary(procutil.stdout)
22 procutil.setbinary(procutil.stdout)
25
23
26 environ = dict(os.environ.items()) # re-exports
24 environ = {
25 k.decode('iso8859-1'): v.decode('iso8859-1')
26 for k, v in encoding.environ.items()
27 } # re-exports
27 environ.setdefault('PATH_INFO', '')
28 environ.setdefault('PATH_INFO', '')
28 if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
29 if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
29 # IIS includes script_name in PATH_INFO
30 # IIS includes script_name in PATH_INFO
General Comments 0
You need to be logged in to leave comments. Login now