Patch #34969 » 0001-Remove-duplicate-code.patch
lib/redmine/thumbnail.rb | ||
---|---|---|
34 | 34 |
return nil if is_pdf && !gs_available? |
35 | 35 | |
36 | 36 |
unless File.exists?(target) |
37 |
# Make sure we only invoke Imagemagick if the file type is allowed |
|
37 | 38 |
mime_type = File.open(source) {|f| MimeMagic.by_magic(f).try(:type)} |
38 | 39 |
return nil if mime_type.nil? |
39 | 40 |
return nil if !ALLOWED_TYPES.include? mime_type |
40 | 41 |
return nil if is_pdf && mime_type != "application/pdf" |
41 | 42 | |
42 |
# Make sure we only invoke Imagemagick if the file type is allowed |
|
43 |
unless File.open(source) {|f| ALLOWED_TYPES.include? MimeMagic.by_magic(f).try(:type)} |
|
44 |
return nil |
|
45 |
end |
|
46 | ||
47 | 43 |
directory = File.dirname(target) |
48 | 44 |
unless File.exists?(directory) |
49 | 45 |
FileUtils.mkdir_p directory |