hgweb: improve IIS PATH_INFO fix ee8af8a4d905 (issue1580) stable
authorPatrick Mezard <pmezard@gmail.com>
Sun, 03 Jan 2010 17:26:39 +0100
branchstable
changeset 10201 d2847c4523e8
parent 10194 a275c3997e03
child 10202 dcaa80294c79
child 10203 6e26e3c2083f
hgweb: improve IIS PATH_INFO fix ee8af8a4d905 (issue1580) Copy PHP IIS detection.
mercurial/hgweb/wsgicgi.py
--- a/mercurial/hgweb/wsgicgi.py	Fri Jan 01 17:58:35 2010 -0600
+++ b/mercurial/hgweb/wsgicgi.py	Sun Jan 03 17:26:39 2010 +0100
@@ -17,8 +17,11 @@
 
     environ = dict(os.environ.iteritems())
     environ.setdefault('PATH_INFO', '')
-    if '.cgi' in environ['PATH_INFO']:
-        environ['PATH_INFO'] = environ['PATH_INFO'].split('.cgi', 1)[1]
+    if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
+        # IIS includes script_name in path_info
+        scriptname = environ['SCRIPT_NAME']
+        if environ['PATH_INFO'].startswith(scriptname):
+            environ['PATH_INFO'] = environ['PATH_INFO'][len(scriptname):]
 
     environ['wsgi.input'] = sys.stdin
     environ['wsgi.errors'] = sys.stderr