Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7871 -- Added some more bullet-proofing in PATH_INFO determina…

…tion,

since Django would like it to at least contain a '/' (rather than being an
empty string).


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8032 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c236874c48fff6509027ee08135eaf3171023917 1 parent 1ef86fd
Malcolm Tredinnick authored July 21, 2008
5  django/core/handlers/modpython.py
@@ -31,6 +31,11 @@ def __init__(self, req):
31 31
             self.path_info = force_unicode(req.uri[len(root):])
32 32
         else:
33 33
             self.path_info = self.path
  34
+        if not self.path_info:
  35
+            # Django prefers empty paths to be '/', rather than '', to give us
  36
+            # a common start character for URL patterns. So this is a little
  37
+            # naughty, but also pretty harmless.
  38
+            self.path_info = u'/'
34 39
 
35 40
     def __repr__(self):
36 41
         # Since this is called as part of error handling, we need to be very
8  django/core/handlers/wsgi.py
@@ -76,7 +76,13 @@ def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0):
76 76
 class WSGIRequest(http.HttpRequest):
77 77
     def __init__(self, environ):
78 78
         script_name = base.get_script_name(environ)
79  
-        path_info = force_unicode(environ.get('PATH_INFO', '/'))
  79
+        path_info = force_unicode(environ.get('PATH_INFO', u'/'))
  80
+        if not path_info:
  81
+            # Sometimes PATH_INFO exists, but is empty (e.g. accessing
  82
+            # the SCRIPT_NAME URL without a trailing slash). We really need to
  83
+            # operate as if they'd requested '/'. Not amazingly nice to force
  84
+            # the path like this, but should be harmless.
  85
+            path_info = u'/'
80 86
         self.environ = environ
81 87
         self.path_info = path_info
82 88
         self.path = '%s%s' % (script_name, path_info)

0 notes on commit c236874

Please sign in to comment.
Something went wrong with that request. Please try again.