Ticket #16541: ticket-16541.diff

File ticket-16541.diff, 3.0 KB (added by kinpoo, 4 years ago)
  • django/core/handlers/modpython.py

    diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
    index eba9dd3..6be33a0 100644
    a b class ModPythonRequest(http.HttpRequest): 
    3232        # circumstances (it's out of mod_python's control a bit), so we use
    3333        # req.uri and some string manipulations to get the right value.
    3434        if root and req.uri.startswith(root):
    35             self.path_info = force_unicode(req.uri[len(root):])
     35            self.path_info = force_unicode(req.uri[len(root):], errors='ignore')
    3636        else:
    3737            self.path_info = self.path
    3838        if not self.path_info:
    class ModPythonHandler(BaseHandler): 
    149149        set_script_prefix(req.get_options().get('django.root', ''))
    150150        signals.request_started.send(sender=self.__class__)
    151151        try:
    152             try:
    153                 request = self.request_class(req)
    154             except UnicodeDecodeError:
    155                 logger.warning('Bad Request (UnicodeDecodeError)',
    156                     exc_info=sys.exc_info(),
    157                     extra={
    158                         'status_code': 400,
    159                     }
    160                 )
    161                 response = http.HttpResponseBadRequest()
    162             else:
    163                 response = self.get_response(request)
     152            request = self.request_class(req)
     153            response = self.get_response(request)
    164154        finally:
    165155            signals.request_finished.send(sender=self.__class__)
    166156
  • django/core/handlers/wsgi.py

    diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
    index 56d2ba6..c121ce3 100644
    a b class LimitedStream(object): 
    115115class WSGIRequest(http.HttpRequest):
    116116    def __init__(self, environ):
    117117        script_name = base.get_script_name(environ)
    118         path_info = force_unicode(environ.get('PATH_INFO', u'/'))
     118        path_info = force_unicode(environ.get('PATH_INFO', u'/'), errors='ignore')
    119119        if not path_info or path_info == script_name:
    120120            # Sometimes PATH_INFO exists, but is empty (e.g. accessing
    121121            # the SCRIPT_NAME URL without a trailing slash). We really need to
    class WSGIHandler(base.BaseHandler): 
    216216        set_script_prefix(base.get_script_name(environ))
    217217        signals.request_started.send(sender=self.__class__)
    218218        try:
    219             try:
    220                 request = self.request_class(environ)
    221             except UnicodeDecodeError:
    222                 logger.warning('Bad Request (UnicodeDecodeError)',
    223                     exc_info=sys.exc_info(),
    224                     extra={
    225                         'status_code': 400,
    226                     }
    227                 )
    228                 response = http.HttpResponseBadRequest()
    229             else:
    230                 response = self.get_response(request)
     219            request = self.request_class(environ)
     220            response = self.get_response(request)
    231221        finally:
    232222            signals.request_finished.send(sender=self.__class__)
    233223
Back to Top