]> source.dussan.org Git - redmine.git/commitdiff
Replace MimeMagic with Marcel (#34969).
authorGo MAEDA <maeda@farend.jp>
Sat, 27 Mar 2021 10:23:47 +0000 (10:23 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 27 Mar 2021 10:23:47 +0000 (10:23 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@20862 e93f8b46-1217-0410-a6f0-8f06a7374b81

Gemfile
lib/redmine/thumbnail.rb

diff --git a/Gemfile b/Gemfile
index b4ab703bacb6fbdc8f2a3a514ce2276045e9f688..443cd04d767e1ba8e4a336a0c52f16daf319f823 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -10,7 +10,7 @@ gem 'request_store', '~> 1.5.0'
 gem "mini_mime", "~> 1.0.1"
 gem "actionpack-xml_parser"
 gem 'roadie-rails', (RUBY_VERSION < '2.5' ? '~> 1.3.0' : '~> 2.2.0')
-gem "mimemagic"
+gem 'marcel'
 gem "mail", "~> 2.7.1"
 gem 'csv', (RUBY_VERSION < '2.5' ? ['>= 3.1.1', '<= 3.1.5'] : '~> 3.1.1')
 gem 'nokogiri', (RUBY_VERSION < '2.5' ? '~> 1.10.0' : '~> 1.11.1')
index 53a0f53503fd7fb82105b9921eb6bd4ff215f996..4bee4085a35a32e085ec05ed34ec8b2d84197ebc 100644 (file)
@@ -18,7 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require 'fileutils'
-require 'mimemagic'
 
 module Redmine
   module Thumbnail
@@ -35,8 +34,7 @@ module Redmine
 
       unless File.exists?(target)
         # Make sure we only invoke Imagemagick if the file type is allowed
-        mime_type = File.open(source) {|f| MimeMagic.by_magic(f).try(:type)}
-        return nil if mime_type.nil?
+        mime_type = File.open(source) {|f| Marcel::MimeType.for(f)}
         return nil if !ALLOWED_TYPES.include? mime_type
         return nil if is_pdf && mime_type != "application/pdf"