summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-20 08:31:05 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-20 08:31:05 +0000
commit5ef7c4c525c1e493c3feaf89606a5c1b36acdfc3 (patch)
tree6e906e0fcfff04c9f4fe78203b6258b8c32dff07
parentcb38521487832999ac2ec147ab5dc96a96bc25ab (diff)
Fixed #5762 -- Quoted the portions that make up the URL when appending
"www." or adding a trailing slash in common middleware. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6553 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/middleware/common.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 57af4eb481..10a3a71b8d 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -1,8 +1,10 @@
+import md5
+import re
+
from django.conf import settings
from django import http
from django.core.mail import mail_managers
-import md5
-import re
+from django.utils.http import urlquote
class CommonMiddleware(object):
"""
@@ -46,9 +48,9 @@ class CommonMiddleware(object):
if new_url != old_url:
# Redirect
if new_url[0]:
- newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], new_url[1])
+ newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], urlquote(new_url[1]))
else:
- newurl = new_url[1]
+ newurl = urlquote(new_url[1])
if request.GET:
newurl += '?' + request.GET.urlencode()
return http.HttpResponsePermanentRedirect(newurl)