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

Fix support of JSON body in /store-invite requests #170

Merged
merged 1 commit into from
Jul 9, 2019

Commits on Jul 8, 2019

  1. Fix support of JSON body in /store-invite requests

    The spec says that /store-invite requests should be done using the 'application/json' mimetype, but currently Sydent chokes on such requests, because it first extracts its params from the request, doing the right thing if the content-type is JSON, but, when trying to compute the dict of substitutions to apply to the email template, looks for them in request.args, which is empty when using 'application/json'.
    
    On top of that, json.dumps() outputs a dict which keys and string values are of type 'unicode', which Python 2 doesn't consider to be strings (or at least not the same as 'str'), so the arguments wouldn't be added to the substitutions dict.
    
    This bug went unnoticed because Synapse isn't compliant with the spec here and sends that data using the 'application/x-www-form-urlencoded' mimetype. This is tracked in matrix-org/synapse#5634.
    
    This makes Sydent not try to re-extract the params from the request.args, but instead use the ones it has already extracted the right way. It also changes the type comparison on the params' values, comparing them with six.string_types instead of only the 'str' type.
    babolivier committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    3f78719 View commit details
    Browse the repository at this point in the history