about summary refs log tree commit diff
path: root/lib/paperclip
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-07-08 16:25:03 +0200
committerGitHub <noreply@github.com>2020-07-08 16:25:03 +0200
commit54e62f8500e69fb0172d565d062354bc6c19b012 (patch)
treeb5ff100059ab31e064c33f5df8f33301febb5609 /lib/paperclip
parentc41da2e96294dc24ba7e039cd3151916fff664db (diff)
parent11446be6d13f6d4748227a329dcc75c5c78c915d (diff)
Merge pull request #1378 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib/paperclip')
-rw-r--r--lib/paperclip/media_type_spoof_detector_extensions.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/paperclip/media_type_spoof_detector_extensions.rb b/lib/paperclip/media_type_spoof_detector_extensions.rb
index 9c0557356..363934d8d 100644
--- a/lib/paperclip/media_type_spoof_detector_extensions.rb
+++ b/lib/paperclip/media_type_spoof_detector_extensions.rb
@@ -2,8 +2,16 @@
 
 module Paperclip
   module MediaTypeSpoofDetectorExtensions
-    def calculated_content_type
-      @calculated_content_type ||= type_from_mime_magic || type_from_file_command
+    def mapping_override_mismatch?
+      !Array(mapped_content_type).include?(calculated_content_type) && !Array(mapped_content_type).include?(type_from_mime_magic)
+    end
+
+    def calculated_media_type_from_mime_magic
+      @calculated_media_type_from_mime_magic ||= type_from_mime_magic.split('/').first
+    end
+
+    def calculated_type_mismatch?
+      !media_types_from_name.include?(calculated_media_type) && !media_types_from_name.include?(calculated_media_type_from_mime_magic)
     end
 
     def type_from_mime_magic