diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-09-23 19:43:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-23 19:43:06 +0200 |
commit | ed56a031041a868eeeb439d8b79d04565be1286f (patch) | |
tree | ce6a75a8a34c92f2291a2188845ce2084e069b89 /activestorage/lib | |
parent | 22dc2b3db894cb709c132456d787166839455a8e (diff) | |
parent | 890485cfce4c361c03a41ec23b0ba187007818cc (diff) | |
download | rails-ed56a031041a868eeeb439d8b79d04565be1286f.tar.gz rails-ed56a031041a868eeeb439d8b79d04565be1286f.tar.bz2 rails-ed56a031041a868eeeb439d8b79d04565be1286f.zip |
Merge pull request #33829 from mtsmfm/encode-filename
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 |