Normalize file parameters in same place as other parameters (ActionDispatch::Http::Parameters#normalize_encode_params)
This commit is contained in:
parent
a4d4af4083
commit
5e6a8b9119
@ -59,6 +59,8 @@ def reset_parameters #:nodoc:
|
||||
def normalize_encode_params(params)
|
||||
if params.is_a?(String)
|
||||
return params.force_encoding(Encoding::UTF_8).encode!
|
||||
elsif Hash === params && params.has_key?(:tempfile)
|
||||
return UploadedFile.new(params)
|
||||
elsif !params.is_a?(Hash)
|
||||
return params
|
||||
end
|
||||
|
@ -18,7 +18,6 @@ class Request < Rack::Request
|
||||
include ActionDispatch::Http::MimeNegotiation
|
||||
include ActionDispatch::Http::Parameters
|
||||
include ActionDispatch::Http::FilterParameters
|
||||
include ActionDispatch::Http::Upload
|
||||
include ActionDispatch::Http::URL
|
||||
|
||||
autoload :Session, 'action_dispatch/request/session'
|
||||
|
@ -73,18 +73,5 @@ def encode_filename(filename)
|
||||
filename.force_encoding(Encoding::UTF_8).encode! if filename
|
||||
end
|
||||
end
|
||||
|
||||
module Upload # :nodoc:
|
||||
# Replace file upload hash with UploadedFile objects
|
||||
# when normalize and encode parameters.
|
||||
def normalize_encode_params(value)
|
||||
if Hash === value && value.has_key?(:tempfile)
|
||||
UploadedFile.new(value)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
private :normalize_encode_params
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user