Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

webapp incorrectly passes non-utf8 charset header to webob #131

Open
mikelambert opened this issue Oct 5, 2017 · 0 comments
Open

webapp incorrectly passes non-utf8 charset header to webob #131

mikelambert opened this issue Oct 5, 2017 · 0 comments

Comments

@mikelambert
Copy link
Contributor

mikelambert commented Oct 5, 2017

I occasionally get these errors when using webapp2 on GAE:

  File "/env/local/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 274, in handle
    keepalive = self.handle_request(req, conn)
  File "/env/local/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 328, in handle_request
    for item in respiter:
  File "/env/local/lib/python2.7/site-packages/webapp2.py", line 1523, in __call__
    with self.request_context_class(self, environ) as (request, response):
  File "/env/local/lib/python2.7/site-packages/webapp2.py", line 1408, in __enter__
    request = self.app.request_class(self.environ)
  File "/env/local/lib/python2.7/site-packages/webapp2.py", line 155, in __init__
    super(Request, self).__init__(environ, *args, **kwargs)
  File "/env/local/lib/python2.7/site-packages/webob/request.py", line 137, in __init__
    "req.decode(charset)``" % charset
DeprecationWarning: You passed charset='iso-8859-1' to the Request constructor. As of WebOb 1.2, if your application needs a non-UTF-8 request charset, please construct the request without a charset or with a charset of 'None',  then use ``req = req.decode(charset)``

I believe it's due to the http client passing a content-type header with charset=, which webapp2 is parsing and passing in to the Request() constructor:

https://github.com/GoogleCloudPlatform/webapp2/blob/master/webapp2.py#L180

It looks like this is only done for non-versioned webob (ie 0.9). Unfortunately, my installation of webob==1.6.1 seems to not have a version, either. My version of webob, however, does raise an error if a non-utf8 charset is passed-in:
https://github.com/Pylons/webob/blob/master/src/webob/request.py#L128

So I get errors when the client passes a non-utf8 charset, as webapp2 then passes it all the way through to trigger the error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant