#26669: UnicodeDecodeError with non-ASCII string in 'Content-Type' header
-------------------------+-------------------------------------------------
     Reporter:  karech   |      Owner:  nobody
         Type:  Bug      |     Status:  new
    Component:  HTTP     |    Version:  1.8
  handling               |   Keywords:  UnicodeDecodeError request META
     Severity:  Normal   |  CONTENT_TYPE Content-Type
 Triage Stage:           |  Has patch:  0
  Unreviewed             |
Easy pickings:  0        |      UI/UX:  0
-------------------------+-------------------------------------------------
 If someone sends POST request with headers containing non-ASCII value for
 'Content-Type', then django raises UnicodeDecodeError.

 {{{#!python
 Traceback (most recent call last):
   File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
     self.result = application(self.environ, self.start_response)
   File "/usr/lib/python2.7/site-
 packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
     return self.application(environ, start_response)
   File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
 line 189, in __call__
     response = self.get_response(request)
   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py",
 line 218, in get_response
     response = self.handle_uncaught_exception(request, resolver,
 sys.exc_info())
   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py",
 line 261, in handle_uncaught_exception
     return debug.technical_500_response(request, *exc_info)
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 97,
 in technical_500_response
     html = reporter.get_traceback_html()
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 383,
 in get_traceback_html
     c = Context(self.get_traceback_data(), use_l10n=False)
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 328,
 in get_traceback_data
     frames = self.get_traceback_frames()
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 501,
 in get_traceback_frames
     'vars': self.filter.get_traceback_frame_variables(self.request,
 tb.tb_frame),
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 234,
 in get_traceback_frame_variables
     cleansed[name] = self.cleanse_special_types(request, value)
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 191,
 in cleanse_special_types
     value = self.get_request_repr(value)
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 122,
 in get_request_repr
     return build_request_repr(request,
 POST_override=self.get_post_parameters(request))
   File "/usr/lib/python2.7/site-packages/django/views/debug.py", line 186,
 in get_post_parameters
     return request.POST
   File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
 line 137, in _get_post
     self._load_post_and_files()
   File "/usr/lib/python2.7/site-packages/django/http/request.py", line
 253, in _load_post_and_files
     if self.META.get('CONTENT_TYPE', '').startswith('multipart/form-
 data'):
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0:
 ordinal not in range(128)
 }}}

 How reproduce:
 {{{#!python
 import requests

 url = 'http://somesite.com/view_with_post_method'
 headers = {'Content-Type': b'\xf0'}
 requests.post(url, headers=headers)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26669>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.939440f5fc5f1bab6760e9feb53b5b13%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to