]> cat aescling's git repositories - mastodon.git/commitdiff
Fix attachments getting processed despite failing content-type validation
authorClaire <claire.github-309c@sitedethib.com>
Thu, 8 Jun 2023 07:32:30 +0000 (09:32 +0200)
committerClaire <claire.github-309c@sitedethib.com>
Thu, 6 Jul 2023 13:30:35 +0000 (15:30 +0200)
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/models/concerns/attachmentable.rb

index 01fae4236fea124bfb0a01fdaedb682eed44069f..35819003e7d3fd1f85b3a1d820f0d424d38f0e1c 100644 (file)
@@ -22,15 +22,14 @@ module Attachmentable
 
   included do
     def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName
-      options = { validate_media_type: false }.merge(options)
       super(name, options)
-      send(:"before_#{name}_post_process") do
+
+      send(:"before_#{name}_validate") do
         attachment = send(name)
         check_image_dimension(attachment)
         set_file_content_type(attachment)
         obfuscate_file_name(attachment)
         set_file_extension(attachment)
-        Paperclip::Validators::MediaTypeSpoofDetectionValidator.new(attributes: [name]).validate(self)
       end
     end
   end