diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-05-05 18:26:25 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-05-05 18:26:25 +0000 |
commit | 515350ed56a1e0f75c81fe6425f8671e8ed5052d (patch) | |
tree | 70ce6b703310cb9a5c599939e847a9a7c78bec14 | |
parent | fef26735514d48cb457d4e2c011724112abaf971 (diff) | |
download | redmine-515350ed56a1e0f75c81fe6425f8671e8ed5052d.tar.gz redmine-515350ed56a1e0f75c81fe6425f8671e8ed5052d.zip |
Merged r15362 (#22721).
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@15364 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | lib/redmine/thumbnail.rb | 5 |
2 files changed, 6 insertions, 0 deletions
@@ -14,6 +14,7 @@ gem "protected_attributes" gem "actionpack-action_caching" gem "actionpack-xml_parser" gem "loofah", "~> 2.0" +gem "mimemagic" # Request at least nokogiri 1.6.7.2 because of security advisories gem "nokogiri", ">= 1.6.7.2" diff --git a/lib/redmine/thumbnail.rb b/lib/redmine/thumbnail.rb index 61e113d5e..9321c7bb3 100644 --- a/lib/redmine/thumbnail.rb +++ b/lib/redmine/thumbnail.rb @@ -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 |