oauth-plugin icon indicating copy to clipboard operation
oauth-plugin copied to clipboard

Ruby 1.9.1. issue

Open aaronchi opened this issue 16 years ago • 3 comments

I get this error in ruby 1.9.1 calling out to an authentication url. This works in ruby 1.8.7

TypeError in Oauth consumersController#show

can't dup Symbol

RAILS_ROOT: C:/sites/bizii Application Trace | Framework Trace | Full Trace

C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1529:in dup' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1529:inurlencode' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:in block in encode_kvpair' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:inmap' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:in encode_kvpair' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:inblock in set_form_data' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:in each' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:inmap' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:in set_form_data' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:324:increate_http_request' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:176:in create_signed_request' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:149:inrequest' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:183:in token_request' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:128:inget_request_token'

aaronchi avatar Nov 25 '09 07:11 aaronchi

Looks like I'm having the same issue. I'm using OAuth with the twitter gem and get this error when I attempt to update. Were you able to find a workaround?

jefflarkin avatar Mar 01 '10 22:03 jefflarkin

Same here using twitter gem. Workaround: add str=str.to_s before line 1532 of net/http.rb (but this is a dirty one, i know!)

pbosetti avatar Mar 22 '10 15:03 pbosetti

More cleanly, you could add this at the beginning of your script, after including your gems:

if RUBY_VERSION =~ /^1\.9/
  module Net
    module HTTPHeader
      def urlencode(str)
        str = str.to_s
        str.dup.force_encoding('ASCII-8BIT').gsub(/[^a-zA-Z0-9_\.\-]/){'%%%02x' % $&.ord}
      end
      private :urlencode
    end
  end
end

pbosetti avatar Mar 23 '10 08:03 pbosetti