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

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

@mikelambert

Description

@mikelambert

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions