mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #29063 from sepehr500/master
Fixed Frozen string error in actionpack
This commit is contained in:
commit
385d9af299
2 changed files with 12 additions and 2 deletions
|
@ -27,14 +27,18 @@ module ActionDispatch
|
||||||
@tempfile = hash[:tempfile]
|
@tempfile = hash[:tempfile]
|
||||||
raise(ArgumentError, ":tempfile is required") unless @tempfile
|
raise(ArgumentError, ":tempfile is required") unless @tempfile
|
||||||
|
|
||||||
@original_filename = hash[:filename]
|
if hash[:filename]
|
||||||
if @original_filename
|
@original_filename = hash[:filename].dup
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@original_filename.encode!(Encoding::UTF_8)
|
@original_filename.encode!(Encoding::UTF_8)
|
||||||
rescue EncodingError
|
rescue EncodingError
|
||||||
@original_filename.force_encoding(Encoding::UTF_8)
|
@original_filename.force_encoding(Encoding::UTF_8)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@original_filename = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@content_type = hash[:type]
|
@content_type = hash[:type]
|
||||||
@headers = hash[:head]
|
@headers = hash[:head]
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,12 @@ module ActionDispatch
|
||||||
assert_equal "foo", uf.original_filename
|
assert_equal "foo", uf.original_filename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_filename_is_different_object
|
||||||
|
file_str = "foo"
|
||||||
|
uf = Http::UploadedFile.new(filename: file_str, tempfile: Object.new)
|
||||||
|
assert_not_equal file_str.object_id , uf.original_filename.object_id
|
||||||
|
end
|
||||||
|
|
||||||
def test_filename_should_be_in_utf_8
|
def test_filename_should_be_in_utf_8
|
||||||
uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
|
uf = Http::UploadedFile.new(filename: "foo", tempfile: Object.new)
|
||||||
assert_equal "UTF-8", uf.original_filename.encoding.to_s
|
assert_equal "UTF-8", uf.original_filename.encoding.to_s
|
||||||
|
|
Loading…
Reference in a new issue