Skip to content

Commit

Permalink
Encode body even if charset doesn't match case
Browse files Browse the repository at this point in the history
As long as the charset is a known one according to Ruby's matching algorithm (which appears to be case insensitive and also includes aliases), we should use that encoding.

Fixes jnunemaker#542 (and maybe jnunemaker#541 as well)
  • Loading branch information
Mr0grog committed Jun 2, 2017
1 parent 304e686 commit 8c2230c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,10 @@ def get_charset
end

def encode_with_ruby_encoding(body, charset)
if !body.nil? && Encoding.name_list.include?(charset)
body.force_encoding(charset)
else
body
end
encoding = Encoding.find(charset)
body.force_encoding(charset)
rescue ArgumentError
body
end

def assume_utf16_is_big_endian
Expand Down

0 comments on commit 8c2230c

Please sign in to comment.