diff options
author | Adrian Holovaty <adrian@holovaty.com> | 2006-06-20 04:06:16 +0000 |
---|---|---|
committer | Adrian Holovaty <adrian@holovaty.com> | 2006-06-20 04:06:16 +0000 |
commit | 7aec348677543de53552738e5dcbfd7cd496c58d (patch) | |
tree | e22f840bc3d94c082d19f5999a86da6b9db9b366 | |
parent | 6b730e1e92eb85beb3d3f7401ee5dce50895d758 (diff) | |
download | django-7aec348677543de53552738e5dcbfd7cd496c58d.tar.gz |
Fixed #2078 -- Improved HttpResponseRedirect and HttpResponsePermanentRedirect 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
-rw-r--r-- | django/http/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index efc1286f6d..8fb4b293fc 100644 --- a/django/http/__init__.py +++ b/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 @@ class HttpResponse(object): 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): |