Vote #80010
完了Safari adds .html extension when downloading files of unknown type
0%
説明
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)
journals
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]*
<pre>
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
</pre>
*[trunk]*
<pre>
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
</pre>
--------------------------------------------------------------------------------
The following patch fixes the problem.
<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
Thank you for testing and providing a fix for this! Looking forward to the release of 4.0.4
--------------------------------------------------------------------------------
Committed the fix. Thank you for reporting this issue.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------