RubyRedditAPI icon indicating copy to clipboard operation
RubyRedditAPI copied to clipboard

submission.comments does not correctly encode non-english characters

Open christosporios opened this issue 13 years ago • 0 comments

r.comments

Throws the following error:

/Users/chris/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:156:in `split': bad URI(is not URI?): /r/test/comments/whogi/ну_написал_я_текст_и_что_с_таво/.json (URI::InvalidURIError)
from /Users/chris/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:174:in `parse'
from /Users/chris/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:628:in `parse'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/httparty-0.8.3/lib/httparty/request.rb:41:in `path='
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/httparty-0.8.3/lib/httparty/request.rb:31:in `initialize'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/httparty-0.8.3/lib/httparty.rb:400:in `new'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/httparty-0.8.3/lib/httparty.rb:400:in `perform_request'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/httparty-0.8.3/lib/httparty.rb:347:in `get'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/ruby_reddit_api-0.2.6/lib/ruby_reddit_api/base.rb:83:in `read'
from /Users/chris/.rvm/gems/ruby-1.9.2-p290@global/gems/ruby_reddit_api-0.2.6/lib/ruby_reddit_api/submission.rb:61:in `comments'
from /Users/chris/code/projects/LUHGDFbot/luhgdf_bot.rb:20:in `block in run'
from /Users/chris/code/projects/LUHGDFbot/luhgdf_bot.rb:16:in `each'
from /Users/chris/code/projects/LUHGDFbot/luhgdf_bot.rb:16:in `run'
from run.rb:10:in `<main>'

I assume this has something to do with the Russian (?) characters, since the method works for every other submission. Chrome encodes the url as:

http://www.reddit.com/r/test/comments/whogi/%D0%BD%D1%83_%D0%BD%D0%B0%D0%BF%D0%B8%D1%81%D0%B0%D0%BB_%D1%8F_%D1%82%D0%B5%D0%BA%D1%81%D1%82_%D0%B8_%D1%87%D1%82%D0%BE_%D1%81_%D1%82%D0%B0%D0%B2%D0%BE/.json

christosporios avatar Jul 13 '12 21:07 christosporios