Sha256: d6b198c1f55bb96fdcd32abff8a085e7e6e885202a8f3184055807dbb725dde2
Contents?: true
Size: 707 Bytes
Versions: 1
Compression:
Stored size: 707 Bytes
Contents
module Paperclip class MediaTypeSpoofDetector def self.using(file, name) new(file, name) end def initialize(file, name) @file = file @name = name end def spoofed? if ! @name.blank? ! supplied_file_media_type.include?(calculated_media_type) end end private def supplied_file_media_type MIME::Types.type_for(@name).collect(&:media_type) end def calculated_media_type type_from_file_command.split("/").first end def type_from_file_command begin Paperclip.run("file", "-b --mime-type :file", :file => @file.path) rescue Cocaine::CommandLineError "" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paperclip-4.0.0 | lib/paperclip/media_type_spoof_detector.rb |