Commits

Anonymous committed 4f2a06f

0.11-stable: Applied patch for #8128.

  • Participants
  • Parent commits 958e1bf
  • Branches 0.11-stable

Comments (0)

Files changed (1)

trac/web/standalone.py

 import os
 import sys
 from SocketServer import ThreadingMixIn
+import urllib
 
 from trac import __version__ as VERSION
 from trac.util import autoreload, daemon
         return self.application(environ, start_response)
 
 
+class FlupMiddleware(object):
+
+    def __init__(self, application):
+        self.application = application
+
+    def __call__(self, environ, start_response):
+        environ['PATH_INFO'] = urllib.unquote(environ.get('PATH_INFO', ''))
+        return self.application(environ, start_response)
+
+
 class TracEnvironMiddleware(object):
 
     def __init__(self, application, env_parent_dir, env_paths, single_env):
                       dest='protocol', callback=_validate_callback,
                       callback_args=(('http', 'scgi', 'ajp'),),
                       help='http|scgi|ajp')
+    parser.add_option('-q', '--unquote', action='store_true',
+                      dest='unquote',
+                      help='unquote PATH_INFO (may be needed when using ajp')
     parser.add_option('-e', '--env-parent-dir', action='store',
                       dest='env_parent_dir', metavar='PARENTDIR',
                       help='parent directory of the project environments')
         def serve():
             server_cls = __import__('flup.server.%s' % options.protocol,
                                     None, None, ['']).WSGIServer
-            ret = server_cls(wsgi_app, bindAddress=server_address).run()
+            flup_app = wsgi_app
+            if options.unquote:
+                flup_app = FlupMiddleware(flup_app)
+            ret = server_cls(flup_app, bindAddress=server_address).run()
             sys.exit(ret and 42 or 0) # if SIGHUP exit with status 42
 
     try: