@@ -14,6 +14,7 gem "protected_attributes" | |||
|
14 | 14 | gem "actionpack-action_caching" |
|
15 | 15 | gem "actionpack-xml_parser" |
|
16 | 16 | gem "roadie-rails" |
|
17 | gem "mimemagic" | |
|
17 | 18 | |
|
18 | 19 | # Request at least nokogiri 1.6.7.2 because of security advisories |
|
19 | 20 | gem "nokogiri", ">= 1.6.7.2" |
@@ -16,6 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'fileutils' |
|
19 | require 'mimemagic' | |
|
19 | 20 | |
|
20 | 21 | module Redmine |
|
21 | 22 | module Thumbnail |
@@ -27,6 +28,10 module Redmine | |||
|
27 | 28 | def self.generate(source, target, size) |
|
28 | 29 | return nil unless convert_available? |
|
29 | 30 | unless File.exists?(target) |
|
31 | # Make sure we only invoke Imagemagick if this is actually an image | |
|
32 | unless File.open(source) {|f| MimeMagic.by_magic(f).try(:image?)} | |
|
33 | return nil | |
|
34 | end | |
|
30 | 35 | directory = File.dirname(target) |
|
31 | 36 | unless File.exists?(directory) |
|
32 | 37 | FileUtils.mkdir_p directory |
General Comments 0
You need to be logged in to leave comments.
Login now