Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest change to __repr__ breaks Flask-Oauthlib? #424

Closed
olegpidsadnyi opened this issue May 9, 2016 · 2 comments
Closed

Latest change to __repr__ breaks Flask-Oauthlib? #424

olegpidsadnyi opened this issue May 9, 2016 · 2 comments

Comments

@olegpidsadnyi
Copy link

Hi,
The regex substitution on the body introduced in the latest PR breaks functionality for Flask-Oauthlib.
There they pass a body as a dictionary for validation, so regex can't work.

Should the body be cast to string before sanitization?

@Alain1405
Copy link

Alain1405 commented May 10, 2016

Here's the traceback:

Traceback (most recent call last):
  File "project/tests/test_main.py", line 120, in test_add_device_user
    token = self.get_access_token()
  File "project/tests/util.py", line 95, in get_access_token
    token_response = self.client.get(url_for('oauth.access_token'), data=data)
  File "project/venv-test/lib/python2.7/site-packages/werkzeug/test.py", line 778, in get
    return self.open(*args, **kw)
  File "project/venv-test/lib/python2.7/site-packages/flask/testing.py", line 108, in open
    follow_redirects=follow_redirects)
  File "project/venv-test/lib/python2.7/site-packages/werkzeug/test.py", line 751, in open
    response = self.run_wsgi_app(environ, buffered=buffered)
  File "project/venv-test/lib/python2.7/site-packages/werkzeug/test.py", line 668, in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
  File "project/venv-test/lib/python2.7/site-packages/werkzeug/test.py", line 871, in run_wsgi_app
    app_rv = app(environ, start_response)
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "project/venv-test/lib/python2.7/site-packages/flask_cors/extension.py", line 110, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "project/venv-test/lib/python2.7/site-packages/flask_cors/extension.py", line 110, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "project/venv-test/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "project/venv-test/lib/python2.7/site-packages/flask_oauthlib/provider/oauth2.py", line 490, in decorated
    uri, http_method, body, headers, credentials
  File "project/venv-test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/endpoints/base.py", line 64, in wrapper
    return f(endpoint, uri, *args, **kwargs)
  File "project/venv-test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/endpoints/token.py", line 100, in create_token_response
    request, self.default_token_type)
  File "project/venv-test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py", line 107, in create_token_response
    log.debug('Validating access token request, %r.', request)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1153, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1284, in _log
    self.handle(record)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1294, in handle
    self.callHandlers(record)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1334, in callHandlers
    hdlr.handle(record)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 757, in handle
    self.emit(record)
  File "project/venv-test/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 82, in emit
    self.buffer.append(self.format(record))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
    return fmt.format(record)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
    record.message = record.getMessage()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
    msg = msg % self.args
  File "project/venv-test/lib/python2.7/site-packages/oauthlib/common.py", line 419, in __repr__
    body = SANITIZE_PATTERN.sub('\1<SANITIZED>', body)
TypeError: expected string or buffer

@threadproc
Copy link
Contributor

I wrote a quick fix for this in #425

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

No branches or pull requests

3 participants