twitter / twurl

OAuth-enabled curl for the Twitter API
https://developer.twitter.com
MIT License
1.8k stars 302 forks source link

twurl posting tweet errors with '&' escape #157

Closed dokimyj closed 1 year ago

dokimyj commented 3 years ago

Describe the bug

Using Twitter API 1.1, the error occurs if option 'status' contains '&' in twurl CLI gem.

To Reproduce Steps to reproduce the behavior:

  1. Install twurl gem (0.9.6)
  2. Auth your Twitter application with twurl.
  3. Try a post command in the command line with twurl -d 'status=bla-bla&foo&bar' /1.1/statuses/update.json.

Expected behavior Post the tweet which contains '&'

Screenshots If applicable, add screenshots to help explain your problem.

twurl -d 'status=改行&テスト' /1.1/statuses/update.json
Traceback (most recent call last):
    13: from ~/.rbenv/versions/2.6.2/bin/twurl:23:in `<main>'
    12: from ~/.rbenv/versions/2.6.2/bin/twurl:23:in `load'
    11: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/bin/twurl:4:in `<top (required)>'
    10: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/cli.rb:21:in `run'
     9: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/cli.rb:40:in `dispatch'
     8: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/abstract_command_controller.rb:7:in `dispatch'
     7: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/request_controller.rb:15:in `dispatch'
     6: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/request_controller.rb:19:in `perform_request'
     5: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:181:in `perform_request_from_options'
     4: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:172:in `build_request_from_options'
     3: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:172:in `map'
     2: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:172:in `each'
     1: from ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:173:in `block in build_request_from_options'
~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/twurl-0.9.6/lib/twurl/oauth_client.rb:173:in `escape': no implicit conversion of nil into String (TypeError)

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Pretty much like the problem comes up due to the lines below...

https://github.com/twitter/twurl/blob/6c2f7bb69225d86e296b8bea94b3aaa4f63a2b87/lib/twurl/oauth_client.rb#L167-L176

smaeda-ks commented 3 years ago

This will be fixed in the coming new version: https://github.com/twitter/twurl/pull/161