diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2018-09-09 16:35:48 +0900 |
---|---|---|
committer | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2018-09-13 21:38:46 +0900 |
commit | 890485cfce4c361c03a41ec23b0ba187007818cc (patch) | |
tree | 1bcf2bccc7cdb710511929dbcb4b68dd602df7f3 /actionpack/lib/action_controller | |
parent | 823f9e0a89707561b54196bf4aabe20c5edb88c1 (diff) | |
download | rails-890485cfce4c361c03a41ec23b0ba187007818cc.tar.gz rails-890485cfce4c361c03a41ec23b0ba187007818cc.tar.bz2 rails-890485cfce4c361c03a41ec23b0ba187007818cc.zip |
Encode Content-Disposition filenames on send_data and send_file
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal/data_streaming.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/metal/data_streaming.rb b/actionpack/lib/action_controller/metal/data_streaming.rb index 5a82ccf668..5140a667de 100644 --- a/actionpack/lib/action_controller/metal/data_streaming.rb +++ b/actionpack/lib/action_controller/metal/data_streaming.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "action_controller/metal/exceptions" +require "action_dispatch/http/content_disposition" module ActionController #:nodoc: # Methods for sending arbitrary data and for streaming files to the browser, @@ -132,10 +133,8 @@ module ActionController #:nodoc: end disposition = options.fetch(:disposition, DEFAULT_SEND_FILE_DISPOSITION) - unless disposition.nil? - disposition = disposition.to_s - disposition += %(; filename="#{options[:filename]}") if options[:filename] - headers["Content-Disposition"] = disposition + if disposition + headers["Content-Disposition"] = ActionDispatch::Http::ContentDisposition.format(disposition: disposition, filename: options[:filename]) end headers["Content-Transfer-Encoding"] = "binary" |