Skip to content
Browse files

all requests are utf-8. Don't use the external encoding.

  • Loading branch information...
1 parent 383d56b commit 383fd143bf6b81d3a1352ddaebb7b4e8beac8b37 @dmathieu dmathieu committed
Showing with 3 additions and 9 deletions.
  1. +2 −3 actionpack/lib/action_dispatch/http/upload.rb
  2. +1 −6 actionpack/test/dispatch/uploaded_file_test.rb
View
5 actionpack/lib/action_dispatch/http/upload.rb
@@ -33,10 +33,9 @@ def size
private
def encode_filename(filename)
- # Encode the filename in the default_external encoding, unless it is nil or we're in 1.8
+ # Encode the filename in the utf8 encoding, unless it is nil or we're in 1.8
if "ruby".encoding_aware? && filename
- encoding = Encoding.default_external
- filename.force_encoding(encoding)
+ filename.force_encoding("UTF-8").encode!
else
filename
end
View
7 actionpack/test/dispatch/uploaded_file_test.rb
@@ -14,12 +14,7 @@ def test_original_filename
end
if "ruby".encoding_aware?
- def test_filename_should_be_in_default_encoding
- Encoding.default_external = "UTF-16LE"
- uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
- assert "UTF-16LE", uf.original_filename.encoding.to_s
-
- Encoding.default_external = "UTF-8"
+ def test_filename_should_be_in_utf_8
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert "UTF-8", uf.original_filename.encoding.to_s
@daeltar
daeltar added a note

Shoud not there be assert_equal instead of plain assert?

Surely it should, my bad. Do you want to make a pull request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end

0 comments on commit 383fd14

Please sign in to comment.
Something went wrong with that request. Please try again.