Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #8381 -- Fixed a problem with appending slashes in the common m…

…iddleware

when SCRIPT_NAME contains something other than '/'. Patch from jcassee.

Also fixed the middleware tests to work with this patch.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8456 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1e1f7c58bc90b583525e3b139c2fed6de362c332 1 parent b9407b2
Malcolm Tredinnick malcolmt authored
4 django/middleware/common.py
View
@@ -54,7 +54,7 @@ def process_request(self, request):
# trailing slash and there is no pattern for the current path
if settings.APPEND_SLASH and (not old_url[1].endswith('/')):
try:
- urlresolvers.resolve(request.path)
+ urlresolvers.resolve(request.path_info)
except urlresolvers.Resolver404:
new_url[1] = new_url[1] + '/'
if settings.DEBUG and request.method == 'POST':
@@ -69,7 +69,7 @@ def process_request(self, request):
if new_url != old_url:
# Redirect if the target url exists
try:
- urlresolvers.resolve(new_url[1])
+ urlresolvers.resolve("%s/" % request.path_info)
except urlresolvers.Resolver404:
pass
else:
2  tests/regressiontests/middleware/tests.py
View
@@ -12,7 +12,7 @@ def _get_request(self, path):
'SERVER_NAME': 'testserver',
'SERVER_PORT': 80,
}
- request.path = "/middleware/%s" % path
+ request.path = request.path_info = "/middleware/%s" % path
return request
def test_append_slash_have_slash(self):
Please sign in to comment.
Something went wrong with that request. Please try again.