Patch #3770

text/html documents force currently firefox to open download dialog

Added by Sam Kvasnica about 8 years ago. Updated over 6 years ago.

Status:NewStart date:2009-08-23
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Attachments
Target version:-

Description

In our redmine installation, we use attach HTML documentation files under project Documentation section (such as asciidoc-generated html code). The problem is, redmine currently forces Firefox browser to open the download dialog instead to open HTML inline in the browser.

As far I traced this down, this is due to setting the Content-Disposition flag to "attachment" by redmine. I could fix this by adding test for is_text mimetype in in attachments_controller.rb:

---snip---
def download
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
@attachment.increment_download
end
  1. :disposition => (@attachment.image? ? 'inline' : 'attachment')
    :disposition => ((@attachment.image? || @attachment.is_text?) ? 'inline' : 'attachment')
    end
    ---snip---
  1. images are sent inline
    send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
    :type => @attachment.content_type,

However, I think this should be handled more in general since there might be pretty much other mimetypes where this is a problem as well.

aaa - attachments_controller.rb fix (584 Bytes) Sam Kvasnica, 2009-08-23 13:38


Related issues

Related to Redmine - Defect #6256: Redmine considers non ASCII and UTF-16 text files as bina... Closed 2010-08-31
Related to Redmine - Feature #2209: MIME type support for repository Entries New 2008-11-17

History

#1 Updated by Sam Kvasnica about 8 years ago

2nd try:

In our redmine installation, we attach HTML documentation files under project Documentation section (such as asciidoc-generated html code). The problem is, redmine currently forces Firefox browser to open the download dialog instead to open HTML inline in the browser.

As far I traced this down, this is due to setting the Content-Disposition flag to "attachment" by redmine. I could fix this by adding test for is_text mimetype in in attachments_controller.rb:

@ ---snip---
def download
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
@attachment.increment_download
end

  1. images are sent inline
    send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
    :type => @attachment.content_type,
  2. :disposition => (@attachment.image? ? 'inline' : 'attachment')
    :disposition => ((@attachment.image? || @attachment.is_text?) ? 'inline' : 'attachment')
    end
---snip---
@
However, I think this should be handled more in general since there might be pretty much other mimetypes where this is a problem as well.

#2 Updated by Sam Kvasnica about 8 years ago

  • File aaa added

3rd try as attachment: verbatim code does not seem to work really...

#3 Updated by Toshi MARUYAMA over 6 years ago

  • Category set to Attachments

Also available in: Atom PDF