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

set_form_data() does not escape "*" (asterisk) in POST body data #117

Closed
jfhbrook opened this issue Aug 11, 2019 · 4 comments
Closed

set_form_data() does not escape "*" (asterisk) in POST body data #117

jfhbrook opened this issue Aug 11, 2019 · 4 comments
Assignees
Labels

Comments

@jfhbrook
Copy link

When trying to send a tweet with an asterisk in it, twurl responds with a "Could not authenticate you." message.

Expected behavior

When I run twurl -X POST -d "status=*tweet*" /1.1/statuses/update.json, it successfully tweets, or complains that the post body is malformed (though I couldn't find anything about asterisks in post bodies being bad...).

Actual behavior

twurl responds with a "Could not authenticate you" message:

{
  "errors": [
    {
      "code": 32,
      "message": "Could not authenticate you."
    }
  ]
}

As concisely as possible, describe the observed behavior.

Steps to reproduce the behavior

  • Authenticate with twurl
  • Try to send a status with an asterisk in it
@smaeda-ks smaeda-ks added the Bug label Nov 28, 2019
@smaeda-ks
Copy link
Collaborator

This seems like an issue with the Net::HTTPHeader module. We use set_form_data() at here:
https://github.com/twitter/twurl/blob/master/lib/twurl/oauth_client.rb#L113-L115

but maybe it's not escaping * properly and resulting in a signature mismatch. I had a workaround that can remediate this (will open a PR) but you can also use query parameters instead.

$ twurl -X POST '/1.1/statuses/update.json?status=*tweet*'

This should work as expected.

@smaeda-ks
Copy link
Collaborator

@jfhbrook Confirmed, set_form_data() does not escape *.
https://github.com/ruby/ruby/blob/v2_6_5/lib/uri/common.rb#L357-L379

* set_form_data() calls URI.encode_www_form(), and URI.encode_www_form() calls encode_www_form_component()

@smaeda-ks smaeda-ks changed the title "Could not authenticate you." when status has an asterisk in it set_form_data() does not escape "*" (asterisk) in POST body data Nov 28, 2019
@smaeda-ks
Copy link
Collaborator

The fix is merged into master.

@smaeda-ks
Copy link
Collaborator

https://github.com/twitter/twurl/releases/tag/v0.9.4

Closing. Again, thanks for your report @jfhbrook !

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

No branches or pull requests

2 participants