Opened 7 years ago

Closed 7 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: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Redirect via next param to url with unicode raise exception:


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:
Installed Middleware:

File "/usr/lib/pymodules/python2.5/django/core/handlers/" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.5/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.5/django/contrib/auth/" in login
  30.             return HttpResponseRedirect(redirect_to)
File "/usr/lib/pymodules/python2.5/django/http/" in __init__
  407.         self['Location'] = redirect_to
File "/usr/lib/pymodules/python2.5/django/http/" in __setitem__
  320.         header, value = self._convert_to_ascii(header, value)
File "/usr/lib/pymodules/python2.5/django/http/" 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 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by Sergey Maranchuk

Attachment: fix.diff added

comment:1 Changed 7 years ago by Karen Tracey

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
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