#12774: Flatpages will cause unicodedecodeerror if request url contains non-ascii characters and no trailing slash ----------------------------------------+----------------------------------- Reporter: a.ne...@gmail.com | Owner: nobody Status: closed | Milestone: 1.2 Component: HTTP handling | Version: 1.2-alpha Resolution: duplicate | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ----------------------------------------+----------------------------------- Changes (by kmtracey):
* status: new => closed * resolution: => duplicate Old description: > If you have flatpages activated, it will choke on a unicodedecodeerror if > the requested url contains a non-ascii character and no trailing slash. > > Example url: > http://www.example.com/%20%C3%A5 > > This will trigger this message: > > Traceback (most recent call last): > > File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", > line 92, in get_response > response = callback(request, *callback_args, **callback_kwargs) > > File "/usr/lib/python2.6/dist- > packages/django/contrib/flatpages/views.py", line 23, in flatpage > return HttpResponseRedirect("%s/" % request.path) > > File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line > 407, in __init__ > self['Location'] = redirect_to > > File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line > 320, in __setitem__ > header, value = self._convert_to_ascii(header, value) > > File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line > 309, in _convert_to_ascii > value = value.encode('us-ascii') > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in > position 3: ordinal not in range(128), HTTP response headers must be in > US-ASCII format New description: If you have flatpages activated, it will choke on a unicodedecodeerror if the requested url contains a non-ascii character and no trailing slash. Example url: http://www.example.com/%20%C3%A5 This will trigger this message: {{{ Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.6/dist- packages/django/contrib/flatpages/views.py", line 23, in flatpage return HttpResponseRedirect("%s/" % request.path) File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line 407, in __init__ self['Location'] = redirect_to File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line 320, in __setitem__ header, value = self._convert_to_ascii(header, value) File "/usr/lib/python2.6/dist-packages/django/http/__init__.py", line 309, in _convert_to_ascii value = value.encode('us-ascii') UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 3: ordinal not in range(128), HTTP response headers must be in US-ASCII format }}} Comment: Reformatted description. This is #11456 exactly. Please search and use preview. -- Ticket URL: <http://code.djangoproject.com/ticket/12774#comment:2> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.