]> cat aescling's git repositories - mastodon.git/commitdiff
Fix ogg vorbis files with a cover art not being correctly processed (#14255)
authorThibG <thib@sitedethib.com>
Tue, 7 Jul 2020 14:32:14 +0000 (16:32 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Jul 2020 14:32:14 +0000 (16:32 +0200)
lib/paperclip/media_type_spoof_detector_extensions.rb

index 9c05573564f16ef0148fc7f325f4e96f63e5fc92..363934d8d1395df9902f2779e6dcf4438315d869 100644 (file)
@@ -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