diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application.rb | 5 | ||||
-rw-r--r-- | app/controllers/attachments_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/documents_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/versions_controller.rb | 3 |
4 files changed, 10 insertions, 3 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 306ebc03c..25cf205f4 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -196,4 +196,9 @@ class ApplicationController < ActionController::Base end return tmp end + + # Returns a string that can be used as filename value in Content-Disposition header + def filename_for_content_disposition(name) + request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name + end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 0913de529..4e87e5442 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -21,7 +21,7 @@ class AttachmentsController < ApplicationController def download # images are sent inline - send_file @attachment.diskfile, :filename => @attachment.filename, + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), :type => @attachment.content_type, :disposition => (@attachment.image? ? 'inline' : 'attachment') rescue diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index b37a8371a..93f25c495 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -67,7 +67,8 @@ class DocumentsController < ApplicationController def download @attachment = @document.attachments.find(params[:attachment_id]) @attachment.increment_download - send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + :type => @attachment.content_type rescue render_404 end diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 1365c97e8..df1be2869 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -42,7 +42,8 @@ class VersionsController < ApplicationController def download @attachment = @version.attachments.find(params[:attachment_id]) @attachment.increment_download - send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + :type => @attachment.content_type rescue render_404 end |