From 701e5b9a19db34834108fdc5fe48923784385ed2 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 7 Jul 2020 16:32:14 +0200 Subject: Fix ogg vorbis files with a cover art not being correctly processed (#14255) --- lib/paperclip/media_type_spoof_detector_extensions.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/paperclip') 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 -- cgit