diff options
author | Jarmo Isotalo <jamo@isotalo.fi> | 2014-04-14 13:09:06 +0300 |
---|---|---|
committer | Jarmo Isotalo <jamo@isotalo.fi> | 2014-05-19 00:03:08 +0300 |
commit | 46890ad18840a3f311bf3bf68e03cc605ca7bf12 (patch) | |
tree | a57b7305f6153c8c3a66d42c14832b37031ef3be /actionpack/lib/action_dispatch/http | |
parent | adffea62b5dc494e0e6bc2ca256bb592ce85f112 (diff) | |
download | rails-46890ad18840a3f311bf3bf68e03cc605ca7bf12.tar.gz rails-46890ad18840a3f311bf3bf68e03cc605ca7bf12.tar.bz2 rails-46890ad18840a3f311bf3bf68e03cc605ca7bf12.zip |
Since upgrading rack we can remove unnecessary string encodings
https://github.com/rack/rack/commit/5a5aee36
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/parameters.rb | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb index dcb299ed03..378dbf6354 100644 --- a/actionpack/lib/action_dispatch/http/parameters.rb +++ b/actionpack/lib/action_dispatch/http/parameters.rb @@ -50,23 +50,16 @@ module ActionDispatch private - # Convert nested Hash to HashWithIndifferentAccess - # and UTF-8 encode both keys and values in nested Hash. + # Convert nested Hash to HashWithIndifferentAccess. # - # TODO: Validate that the characters are UTF-8. If they aren't, - # you'll get a weird error down the road, but our form handling - # should really prevent that from happening def normalize_encode_params(params) case params - when String - params.force_encoding(Encoding::UTF_8).encode! when Hash if params.has_key?(:tempfile) UploadedFile.new(params) else params.each_with_object({}) do |(key, val), new_hash| - new_key = key.is_a?(String) ? key.dup.force_encoding(Encoding::UTF_8).encode! : key - new_hash[new_key] = if val.is_a?(Array) + new_hash[key] = if val.is_a?(Array) val.map! { |el| normalize_encode_params(el) } else normalize_encode_params(val) |