Commits

mtre...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed a16f329

Fixed #7871 -- Added some more bullet-proofing in PATH_INFO determination,
since Django would like it to at least contain a '/' (rather than being an
empty string).

  • Participants
  • Parent commits 64e2229

Comments (0)

Files changed (2)

File django/core/handlers/modpython.py

             self.path_info = force_unicode(req.uri[len(root):])
         else:
             self.path_info = self.path
+        if not self.path_info:
+            # Django prefers empty paths to be '/', rather than '', to give us
+            # a common start character for URL patterns. So this is a little
+            # naughty, but also pretty harmless.
+            self.path_info = u'/'
 
     def __repr__(self):
         # Since this is called as part of error handling, we need to be very

File django/core/handlers/wsgi.py

 class WSGIRequest(http.HttpRequest):
     def __init__(self, environ):
         script_name = base.get_script_name(environ)
-        path_info = force_unicode(environ.get('PATH_INFO', '/'))
+        path_info = force_unicode(environ.get('PATH_INFO', u'/'))
+        if not path_info:
+            # Sometimes PATH_INFO exists, but is empty (e.g. accessing
+            # the SCRIPT_NAME URL without a trailing slash). We really need to
+            # operate as if they'd requested '/'. Not amazingly nice to force
+            # the path like this, but should be harmless.
+            path_info = u'/'
         self.environ = environ
         self.path_info = path_info
         self.path = '%s%s' % (script_name, path_info)