This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Content Type Validation not failing for spoofed video file #2426
Comments
Dug a little deeper. For a pdf file with mp4 extension: So I guess spoof detection will fail on all higher level content type checks. |
Instead of def calculated_media_type
@calculated_media_type ||= calculated_content_type.split("/").first
end how about matching with sub type for spoof detection? def calculated_media_type
@calculated_media_type ||= calculated_content_type.split("/").last.split(';').first
end Not sure about it's side effects though. |
Currently the following patch works for me: module Paperclip
class MediaTypeSpoofDetector
def supplied_type_mismatch?
supplied_media_type.present? && !media_types_from_name.include?(supplied_media_type)
end
def supplied_media_type
@content_type.split("/").last
end
def media_types_from_name
@media_types_from_name ||= content_types_from_name.collect(&:sub_type)
end
def calculated_media_type
@calculated_media_type ||= calculated_content_type.split("/").last.split(';').first
end
end
end |
Looks like we found a workaround, closing. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For the following model
on paperclip '4.3.1', rails '4.2.6', content spoof detector doesn't seem to work when simply renaming data3.pdf file to data3.mp4
According to docs, it should be working since 'file' command is identifying it properly.
Am I missing something here? Or is it a bug?
The text was updated successfully, but these errors were encountered: