Opened 6 years ago

Closed 6 years ago

#12790 closed (duplicate)

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

Reported by: slav0nic 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 slav0nic 6 years ago.

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by slav0nic

comment:1 Changed 6 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

#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