diff options
author | Kohei Suzuki <eagletmt@gmail.com> | 2015-08-05 20:21:40 +0900 |
---|---|---|
committer | Kohei Suzuki <eagletmt@gmail.com> | 2015-08-05 20:24:58 +0900 |
commit | 9521e18ed0c811e70b2ccef309bdaa1250587aa0 (patch) | |
tree | 8950a2110b161b054e04078c26e07846adbe1f45 | |
parent | b5ae1be2cd1aef2f6ed7a53a4684c6b7eb35304f (diff) | |
download | rails-9521e18ed0c811e70b2ccef309bdaa1250587aa0.tar.gz rails-9521e18ed0c811e70b2ccef309bdaa1250587aa0.tar.bz2 rails-9521e18ed0c811e70b2ccef309bdaa1250587aa0.zip |
Assume uploaded filename is UTF-8
-rw-r--r-- | actionpack/lib/action_dispatch/http/upload.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb index 540e11a4a0..a221f4c5af 100644 --- a/actionpack/lib/action_dispatch/http/upload.rb +++ b/actionpack/lib/action_dispatch/http/upload.rb @@ -28,7 +28,13 @@ module ActionDispatch raise(ArgumentError, ':tempfile is required') unless @tempfile @original_filename = hash[:filename] - @original_filename &&= @original_filename.encode "UTF-8" + if @original_filename + begin + @original_filename.encode!(Encoding::UTF_8) + rescue EncodingError + @original_filename.force_encoding(Encoding::UTF_8) + end + end @content_type = hash[:type] @headers = hash[:head] end |