Ticket #1512 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

Error with accentuated characters in URL

Reported by: crumble Owned by: apoirier
Priority: major Component: callbacks & forms
Version: Keywords:
Cc:

Description

Running nagare with standalone publisher
 http://localhost:8080/admin/?property_value=test+%E9%E9%E9

give the following errors

Using webob 1.2b2


Exception happened during processing of request from ('127.0.0.1', 53279)
Traceback (most recent call last):

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread

self.finish_request(request, client_address)

File "/opt/stackless-26-maint/lib/python2.6/SocketServer.py", line 322, in finish_request

self.RequestHandlerClass?(request, client_address, self)

File "/opt/stackless-26-maint/lib/python2.6/SocketServer.py", line 617, in init

self.handle()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 442, in handle

BaseHTTPRequestHandler.handle(self)

File "/opt/stackless-26-maint/lib/python2.6/BaseHTTPServer.py", line 329, in handle

self.handle_one_request()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 437, in handle_one_request

self.wsgi_execute()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 287, in wsgi_execute

self.wsgi_start_response)

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/urlmap.py", line 203, in call

return app(environ, start_response)

File "/Users/herve/Documents/workspace/nagare/nagare-core/nagare/wsgi.py", line 370, in call

channel_id = request.params.get('_channel')

File "build/bdist.macosx-10.4-x86_64/egg/webob/request.py", line 692, in params

params = NestedMultiDict?(self.GET, self.POST)

File "build/bdist.macosx-10.4-x86_64/egg/webob/request.py", line 674, in GET

vars = GetDict?(data, env)

File "build/bdist.macosx-10.4-x86_64/egg/webob/multidict.py", line 273, in init

MultiDict?.init(self, data)

File "build/bdist.macosx-10.4-x86_64/egg/webob/multidict.py", line 37, in init

items = list(args[0])

File "build/bdist.macosx-10.4-x86_64/egg/webob/compat.py", line 125, in parse_qsl_text

yield (x.decode(encoding), y.decode(encoding))

File "/Users/herve/projects/aramis/lib/python2.6/encodings/utf_8.py", line 16, in decode

return codecs.utf_8_decode(input, errors, True)

UnicodeDecodeError?: 'utf8' codec can't decode byte 0xe9 in position 5: invalid continuation byte


Using webob 1.1.1


Exception happened during processing of request from ('127.0.0.1', 53308)
Traceback (most recent call last):

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread

self.finish_request(request, client_address)

File "/opt/stackless-26-maint/lib/python2.6/SocketServer.py", line 322, in finish_request

self.RequestHandlerClass?(request, client_address, self)

File "/opt/stackless-26-maint/lib/python2.6/SocketServer.py", line 617, in init

self.handle()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 442, in handle

BaseHTTPRequestHandler.handle(self)

File "/opt/stackless-26-maint/lib/python2.6/BaseHTTPServer.py", line 329, in handle

self.handle_one_request()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 437, in handle_one_request

self.wsgi_execute()

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 287, in wsgi_execute

self.wsgi_start_response)

File "/Users/herve/projects/aramis/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/urlmap.py", line 203, in call

return app(environ, start_response)

File "/Users/herve/Documents/workspace/nagare/nagare-core/nagare/wsgi.py", line 432, in call

response = self.on_exception(request, response)

File "/Users/herve/Documents/workspace/nagare/nagare-core/nagare/wsgi.py", line 423, in call

render = self._phase1(request, response, callbacks)

File "/Users/herve/Documents/workspace/nagare/nagare-core/nagare/wsgi.py", line 329, in _phase1

return callbacks.process_response(request, response)

File "/Users/herve/Documents/workspace/nagare/nagare-core/nagare/callbacks.py", line 152, in process_response

raise CallbackLookupError?(name[8:])

UnboundLocalError?: local variable 'name' referenced before assignment


Change History

comment:1 Changed 5 years ago by apoirier

  • Status changed from new to closed
  • Resolution set to fixed

In [b3960b5ea8df/core]:

Fixes #1512. Send a 400 http status when a request not encoded in utf-8 is received, instead of a 500 error

comment:2 Changed 5 years ago by apoirier

Nagare expects to receive utf-8 encoded url and parameters, else a 400 http error is now sent back.

In your case, the query string property_value=test+%E9%E9%E9 has an url quoted latin-1 encoded value.

If you really want to be able to process such latin-1 encoded request, you must overwrite the create_request() method of the nagare.wsgi.WSGIApp class:

class WSGIApp(wsgi.WSGIApp):
    def create_request(self, environ):
        r = super(WSGIApp, self).create_request(environ)
        r.url_encoding = 'latin-1'  # the request can have latin-1 encoded url
        return r.decode('latin-1')  # the request can have latin-1 encoded parameters
Note: See TracTickets for help on using tickets.