]> source.dussan.org Git - redmine.git/commitdiff
Merged r15362 (#22721).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 5 May 2016 18:25:57 +0000 (18:25 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 5 May 2016 18:25:57 +0000 (18:25 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15363 e93f8b46-1217-0410-a6f0-8f06a7374b81

Gemfile
lib/redmine/thumbnail.rb

diff --git a/Gemfile b/Gemfile
index 55e11b9dbee9db8d9e002ee2d88b9f65f06478f3..a632dbd4e8457eb887d870b74324d64d50ea5def 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -14,6 +14,7 @@ gem "protected_attributes"
 gem "actionpack-action_caching"
 gem "actionpack-xml_parser"
 gem "roadie-rails"
+gem "mimemagic"
 
 # Request at least nokogiri 1.6.7.2 because of security advisories
 gem "nokogiri", ">= 1.6.7.2"
index 61e113d5e18f1e7a7e0180fea626e8e5890691ac..9321c7bb304b25ef86492c52af50c41167f1eb82 100644 (file)
@@ -16,6 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require 'fileutils'
+require 'mimemagic'
 
 module Redmine
   module Thumbnail
@@ -27,6 +28,10 @@ module Redmine
     def self.generate(source, target, size)
       return nil unless convert_available?
       unless File.exists?(target)
+        # Make sure we only invoke Imagemagick if this is actually an image
+        unless File.open(source) {|f| MimeMagic.by_magic(f).try(:image?)}
+          return nil
+        end
         directory = File.dirname(target)
         unless File.exists?(directory)
           FileUtils.mkdir_p directory