Project

General

Profile

Actions

Defect #31275

closed

Safari adds .html extension when downloading files of unknown type

Added by Christian Felix almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Redmine Version: 4.0.3.stable
Browser Version: Safari 12.1
Operating system: macOS 10.14.4

What is the issue and how can it be reproduced?

This problem only seems to happen in the Safari browser. When trying to download a "irregular" file such as .indd, .idml, etc. from Redmine, it always adds a .html at the end of the file. Downloading a picture file (.jpeg .png .gif etc.) for example, is working perfectly fine and does not get the .html at the end of the filename.

It looks like Redmine adds either the wrong content-type or none at all which may lead to this issue in Safari.

What is the expected behavior?

When downloading any type of file from Redmine with Safari, it should always download the file as is and not add anything at the end of the filename.

Additional info:

At first I thought that it was an issue with Safari as it was working perfectly fine in Chrome or Firefox but as regular files are working in Safari as well, I kind of think that this is a combined issue of Redmine and Safari. (Safari being too straight with file types)

Actions #1

Updated by Go MAEDA almost 5 years ago

  • Category changed from Issues to Attachments
  • Status changed from New to Confirmed

Confirmed that the problem is reproducible in the trunk. No problem with 3.4.

Comparing HTTP headers in Redmine 3.4 and the trunk, I found that the header in the trunk has "Content-Type: text/html; charset=utf-8". This may be the cause.

[3.4-stable]

HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Etag: "c8c16845c9c26151a57d12ea12c26839" 
Content-Disposition: attachment; filename="test.indd" 
Content-Transfer-Encoding: binary
Content-Type:
Cache-Control: private
X-Request-Id: 903252e3-f983-4d73-84f2-b5046dd052ec
X-Runtime: 0.039056
Server: WEBrick/1.3.1 (Ruby/2.2.10/2018-03-28)
Date: Mon, 29 Apr 2019 13:35:02 GMT
Connection: close

[trunk]

HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
ETag: W/"c8c16845c9c26151a57d12ea12c26839" 
Content-Type: text/html; charset=utf-8
Content-Disposition: attachment; filename="test.indd" 
Content-Transfer-Encoding: binary
Cache-Control: private
X-Request-Id: 5eb10b0d-88df-47f4-9d20-4cd473d9c64e
X-Runtime: 0.029546
Date: Mon, 29 Apr 2019 13:35:41 GMT
Connection: close

Actions #2

Updated by Go MAEDA almost 5 years ago

  • Target version set to 4.0.4

The following patch fixes the problem.

Index: app/controllers/attachments_controller.rb
===================================================================
--- app/controllers/attachments_controller.rb    (リビジョン 18097)
+++ app/controllers/attachments_controller.rb    (作業コピー)
@@ -239,7 +239,9 @@
   def detect_content_type(attachment)
     content_type = attachment.content_type
     if content_type.blank? || content_type == "application/octet-stream" 
-      content_type = Redmine::MimeType.of(attachment.filename)
+      content_type =
+        Redmine::MimeType.of(attachment.filename) ||
+        "application/octet-stream" 
     end
     content_type.to_s
   end
Actions #3

Updated by Christian Felix almost 5 years ago

Thank you for testing and providing a fix for this! Looking forward to the release of 4.0.4

Actions #4

Updated by Go MAEDA almost 5 years ago

  • Subject changed from Downloading attachment from Redmine with Safari, always adds .html to the file to Safari adds .html extension when downloading files of unknown type
  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix. Thank you for reporting this issue.

Actions #5

Updated by Go MAEDA almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF