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 /activestorage/lib | |
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 'activestorage/lib')
-rw-r--r-- | activestorage/lib/active_storage/service.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/service.rb b/activestorage/lib/active_storage/service.rb index f915518f52..54ba08fb87 100644 --- a/activestorage/lib/active_storage/service.rb +++ b/activestorage/lib/active_storage/service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require "active_storage/log_subscriber" +require "action_dispatch" +require "action_dispatch/http/content_disposition" module ActiveStorage # Abstract class serving as an interface for concrete services. @@ -122,7 +124,8 @@ module ActiveStorage end def content_disposition_with(type: "inline", filename:) - (type.to_s.presence_in(%w( attachment inline )) || "inline") + "; #{filename.parameters}" + disposition = (type.to_s.presence_in(%w( attachment inline )) || "inline") + ActionDispatch::Http::ContentDisposition.format(disposition: disposition, filename: filename.sanitized) end end end |