Skip to content

Commit

Permalink
Fix remote convertible media attachments not being saved (mastodon#13032
Browse files Browse the repository at this point in the history
)

Because the file name was set after loading the file, Paperclip
was flagging the differing file extension as content type spoofing

Fix mastodon#12938
  • Loading branch information
Gargron authored and multiple creatures committed Feb 21, 2020
1 parent 0f5411b commit b2cb81e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/remotable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def remotable_attachment(attachment_name, limit, suppress_errors: true)

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
Expand Down

0 comments on commit b2cb81e

Please sign in to comment.