|
|
@ -2,8 +2,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
module Paperclip
|
|
|
|
module Paperclip
|
|
|
|
module MediaTypeSpoofDetectorExtensions
|
|
|
|
module MediaTypeSpoofDetectorExtensions
|
|
|
|
def calculated_content_type
|
|
|
|
def mapping_override_mismatch?
|
|
|
|
@calculated_content_type ||= type_from_mime_magic || type_from_file_command
|
|
|
|
!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
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def type_from_mime_magic
|
|
|
|
def type_from_mime_magic
|
|
|
|