Opened 15 years ago

Closed 15 years ago

#12790 closed (duplicate)

redirect_to in django.contrib.auth.views.* must be urlquoted

Reported by: Sergey Maranchuk Owned by: nobody
Component: contrib.auth Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Redirect via next param to url with unicode raise exception:

Environment:

Request Method: POST
Request URL: http://localhost:8009/login?next=/%D0%BF%D0%B8%D0%B4%D0%B0%D1%80%D0%B3%D0%B8/
Django Version: 1.1.1
Python Version: 2.5.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'testbb']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/pymodules/python2.5/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.5/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.5/django/contrib/auth/views.py" in login
  30.             return HttpResponseRedirect(redirect_to)
File "/usr/lib/pymodules/python2.5/django/http/__init__.py" in __init__
  407.         self['Location'] = redirect_to
File "/usr/lib/pymodules/python2.5/django/http/__init__.py" in __setitem__
  320.         header, value = self._convert_to_ascii(header, value)
File "/usr/lib/pymodules/python2.5/django/http/__init__.py" in _convert_to_ascii
  309.                     value = value.encode('us-ascii')

Exception Type: UnicodeEncodeError at /login
Exception Value: 'ascii' codec can't encode characters in position 1-7: ordinal not in range(128), HTTP response headers must be in US-ASCII format

Maybe redirect url must be quoted in HttpResponseRedirect level (#11522) and problem exist not only in contrib.auth ?

Attachments (1)

fix.diff (260 bytes ) - added by Sergey Maranchuk 15 years ago.

Download all attachments as: .zip

Change History (2)

by Sergey Maranchuk, 15 years ago

Attachment: fix.diff added

comment:1 by Karen Tracey, 15 years ago

Resolution: duplicate
Status: newclosed

#11522 is already open for the general problem of an exception when redirecting to URLS containing non-ASCII characters.

Note: See TracTickets for help on using tickets.
Back to Top