@@ -14,6 +14,7 gem "protected_attributes" | |||||
14 | gem "actionpack-action_caching" |
|
14 | gem "actionpack-action_caching" | |
15 | gem "actionpack-xml_parser" |
|
15 | gem "actionpack-xml_parser" | |
16 | gem "roadie-rails" |
|
16 | gem "roadie-rails" | |
|
17 | gem "mimemagic" | |||
17 |
|
18 | |||
18 | # Request at least nokogiri 1.6.7.2 because of security advisories |
|
19 | # Request at least nokogiri 1.6.7.2 because of security advisories | |
19 | gem "nokogiri", ">= 1.6.7.2" |
|
20 | gem "nokogiri", ">= 1.6.7.2" |
@@ -16,6 +16,7 | |||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require 'fileutils' |
|
18 | require 'fileutils' | |
|
19 | require 'mimemagic' | |||
19 |
|
20 | |||
20 | module Redmine |
|
21 | module Redmine | |
21 | module Thumbnail |
|
22 | module Thumbnail | |
@@ -27,6 +28,10 module Redmine | |||||
27 | def self.generate(source, target, size) |
|
28 | def self.generate(source, target, size) | |
28 | return nil unless convert_available? |
|
29 | return nil unless convert_available? | |
29 | unless File.exists?(target) |
|
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 | directory = File.dirname(target) |
|
35 | directory = File.dirname(target) | |
31 | unless File.exists?(directory) |
|
36 | unless File.exists?(directory) | |
32 | FileUtils.mkdir_p directory |
|
37 | FileUtils.mkdir_p directory |
General Comments 0
You need to be logged in to leave comments.
Login now