summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-21 22:13:56 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-21 22:13:56 +0000
commitc236874c48fff6509027ee08135eaf3171023917 (patch)
tree6cd28e5449aa6959c33b2c02c0e69b2757519b4e
parent1ef86fdf2bdc569582a99986b77c57209311e72d (diff)
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). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8032 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/handlers/modpython.py5
-rw-r--r--django/core/handlers/wsgi.py8
2 files changed, 12 insertions, 1 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index d407476acf..58699816fd 100644
--- a/django/core/handlers/modpython.py
+++ b/django/core/handlers/modpython.py
@@ -31,6 +31,11 @@ class ModPythonRequest(http.HttpRequest):
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
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index ca8dd4565f..a1324936cd 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -76,7 +76,13 @@ def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0):
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)