Commit 941f9bf3 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Non-ascii attachement filename fix for IE.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1053 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent a39f655a
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment