プロジェクト

全般

プロフィール

Vote #75170

完了

Support for the 1.x versions of mime-types gem

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

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

0%

予定工数:
category_id:
45
version_id:
84
issue_org_id:
16710
author_id:
100093
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Even though Redmine doesn't specify in its Gemfile a minimum version for the mime-types gem, it still assumes that version is 2.x or later. This is because it uses MIME::Types.find.

Unfortunately, upgrading to mime-types 2.x would break the dependencies of the mail gem.

The attached patch uses MIME::Types.type_for which is present in both 1.x and 2.x versions of mime-types.

Tested with Redmine 2.5.1 + ruby 1.8.7 + rails 3.2.17


journals

@MIME::Types.find@ has been added in @mime-types@ "here":https://github.com/halostatue/mime-types/commit/644259db36c69884735aa66aa6fdee690dfa9f7b.
There is another error if this "additional commit":https://github.com/halostatue/mime-types/commit/fd53425e33046932cebcf0d3d8f92c3e35cd4472 is not used.
Both commits are included in mime-types 1.23.

Particularly @MIME::Types.find@ is used in @lib/redmine/mime_type.rb@ since r12483.

The problem doesn't occur:
* either with mime-types 1.23
* or with mime-types 1.19 when attachment:redmine-2.5.1-mime-types.patch is applied

First error fixed by "644259db36c69884735aa66aa6fdee690dfa9f7b":https://github.com/halostatue/mime-types/commit/644259db36c69884735aa66aa6fdee690dfa9f7b:
<pre>
ActionView::Template::Error (undefined method `find' for MIME::Types:Class):
1: <div class="attachments">
2: <% for attachment in attachments %>
3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
4: <% if attachment.is_text? %>
5: <%= link_to image_tag('magnifier.png'),
6: :controller => 'attachments', :action => 'show',
lib/redmine/mime_type.rb:63:in `block in of'
lib/redmine/mime_type.rb:66:in `yield'
lib/redmine/mime_type.rb:66:in `default'
lib/redmine/mime_type.rb:66:in `of'
lib/redmine/mime_type.rb:78:in `main_mimetype_of'
lib/redmine/mime_type.rb:85:in `is_type?'
app/models/attachment.rb:217:in `is_text?'
app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb___3782281663955472009_30361420'
app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb___3782281663955472009_30361420'
app/helpers/attachments_helper.rb:31:in `link_to_attachments'
app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb___505910332762640252_28753000'
</pre>

Second error fixed by "fd53425e33046932cebcf0d3d8f92c3e35cd4472":https://github.com/halostatue/mime-types/commit/fd53425e33046932cebcf0d3d8f92c3e35cd4472:
<pre>
ActionView::Template::Error (undefined method `extensions' for #<Array:0x000000053ecdf8>):
1: <div class="attachments">
2: <% for attachment in attachments %>
3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
4: <% if attachment.is_text? %>
5: <%= link_to image_tag('magnifier.png'),
6: :controller => 'attachments', :action => 'show',
lib/redmine/mime_type.rb:63:in `block (2 levels) in of'
lib/redmine/mime_type.rb:63:in `find'
lib/redmine/mime_type.rb:63:in `block in of'
lib/redmine/mime_type.rb:66:in `yield'
lib/redmine/mime_type.rb:66:in `default'
lib/redmine/mime_type.rb:66:in `of'
lib/redmine/mime_type.rb:78:in `main_mimetype_of'
lib/redmine/mime_type.rb:85:in `is_type?'
app/models/attachment.rb:217:in `is_text?'
app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb__4198667861296620514_35003500'
app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb__4198667861296620514_35003500'
app/helpers/attachments_helper.rb:31:in `link_to_attachments'
app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb__1410191189284416881_31521860'
</pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Patch committed in r13107, thanks.
--------------------------------------------------------------------------------
Merged.
--------------------------------------------------------------------------------

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

いいね!0
いいね!0