]> cat aescling's git repositories - mastodon.git/commitdiff
Fix remote convertible media attachments not being saved (#13032)
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 3 Feb 2020 17:45:56 +0000 (18:45 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Feb 2020 17:45:56 +0000 (18:45 +0100)
Because the file name was set after loading the file, Paperclip
was flagging the differing file extension as content type spoofing

Fix #12938

app/models/concerns/remotable.rb

index b7a476c87a51548bc8cc47434f50dadceb23c799..c728a460e5f53d0ab128f81dcaaf99c3b735d7a2 100644 (file)
@@ -36,8 +36,8 @@ module Remotable
 
             basename = SecureRandom.hex(8)
 
-            send("#{attachment_name}=", StringIO.new(response.body_with_limit(limit)))
             send("#{attachment_name}_file_name=", basename + extname)
+            send("#{attachment_name}=", StringIO.new(response.body_with_limit(limit)))
 
             self[attribute_name] = url if has_attribute?(attribute_name)
           end