Class: Paperclip::MediaTypeSpoofDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/media_type_spoof_detector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, name) ⇒ MediaTypeSpoofDetector

Returns a new instance of MediaTypeSpoofDetector.



7
8
9
10
# File 'lib/paperclip/media_type_spoof_detector.rb', line 7

def initialize(file, name)
  @file = file
  @name = name
end

Class Method Details

.using(file, name) ⇒ Object



3
4
5
# File 'lib/paperclip/media_type_spoof_detector.rb', line 3

def self.using(file, name)
  new(file, name)
end

Instance Method Details

#spoofed?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
# File 'lib/paperclip/media_type_spoof_detector.rb', line 12

def spoofed?
  if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch?
    Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_file_content_types}), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.")
    true
  end
end