Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #2078 -- Improved HttpResponseRedirect and HttpResponsePermanen…

…tRedirect to percent-encode non-ASCII characters in the Location header. Thanks, Andrey

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3166 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7aec348677543de53552738e5dcbfd7cd496c58d 1 parent 6b730e1
@adrianholovaty adrianholovaty authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 django/http/__init__.py
View
8 django/http/__init__.py
@@ -1,8 +1,10 @@
from Cookie import SimpleCookie
from pprint import pformat
-from urllib import urlencode
+from urllib import urlencode, quote
from django.utils.datastructures import MultiValueDict
+RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
+
try:
# The mod_python version is more efficient, so try importing it first.
from mod_python.util import parse_qsl
@@ -242,13 +244,13 @@ def tell(self):
class HttpResponseRedirect(HttpResponse):
def __init__(self, redirect_to):
HttpResponse.__init__(self)
- self['Location'] = redirect_to
+ self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
self.status_code = 302
class HttpResponsePermanentRedirect(HttpResponse):
def __init__(self, redirect_to):
HttpResponse.__init__(self)
- self['Location'] = redirect_to
+ self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
self.status_code = 301
class HttpResponseNotModified(HttpResponse):
Please sign in to comment.
Something went wrong with that request. Please try again.