diff options
author | Starfall <us@starfall.systems> | 2020-07-11 12:31:22 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-07-11 12:31:22 -0500 |
commit | 2f20bc2a8275875033c97249825a2a3305980c3b (patch) | |
tree | 079a021ab1ce792a40555e0718f9861ee8b53f7a /lib | |
parent | 816d10c7eecd83cb0f115c10328cbb504dabc7e9 (diff) | |
parent | 7a23347db5be3f262dbcafbecf768588dc648bda (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'lib')
-rw-r--r-- | lib/paperclip/media_type_spoof_detector_extensions.rb | 12 |
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 |