プロジェクト

全般

プロフィール

Vote #80010

完了

Safari adds .html extension when downloading files of unknown type

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
151
issue_org_id:
31275
author_id:
398216
assigned_to_id:
332
comments:
5
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
148
ステータス-->[Closed]

説明

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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン4.0.4_151 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0