##// END OF EJS Templates
Non-ascii attachement filename fix for IE....
Jean-Philippe Lang -
r1039:941f9bf3dd3b
parent child
Show More
@@ -196,4 +196,9 class ApplicationController < ActionController::Base
196 196 end
197 197 return tmp
198 198 end
199
200 # Returns a string that can be used as filename value in Content-Disposition header
201 def filename_for_content_disposition(name)
202 request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
203 end
199 204 end
@@ -21,7 +21,7 class AttachmentsController < ApplicationController
21 21
22 22 def download
23 23 # images are sent inline
24 send_file @attachment.diskfile, :filename => @attachment.filename,
24 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
25 25 :type => @attachment.content_type,
26 26 :disposition => (@attachment.image? ? 'inline' : 'attachment')
27 27 rescue
@@ -67,7 +67,8 class DocumentsController < ApplicationController
67 67 def download
68 68 @attachment = @document.attachments.find(params[:attachment_id])
69 69 @attachment.increment_download
70 send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
70 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
71 :type => @attachment.content_type
71 72 rescue
72 73 render_404
73 74 end
@@ -42,7 +42,8 class VersionsController < ApplicationController
42 42 def download
43 43 @attachment = @version.attachments.find(params[:attachment_id])
44 44 @attachment.increment_download
45 send_file @attachment.diskfile, :filename => @attachment.filename, :type => @attachment.content_type
45 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
46 :type => @attachment.content_type
46 47 rescue
47 48 render_404
48 49 end
General Comments 0
You need to be logged in to leave comments. Login now