Skip to content
Snippets Groups Projects
Commit 04046a49 authored by Eugen Rochko's avatar Eugen Rochko Committed by GitHub
Browse files

Fix #4908 - Do not keep remote file names, generate random (#4934)

parent a4c50017
No related branches found
No related tags found
No related merge requests found
......@@ -27,9 +27,11 @@ module Remotable
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/)
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1]
basename = SecureRandom.hex(8)
extname = File.extname(filename)
send("#{attachment_name}=", StringIO.new(response.to_s))
send("#{attachment_name}_file_name=", filename)
send("#{attachment_name}_file_name=", basename + extname)
self[attribute_name] = url if has_attribute?(attribute_name)
rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment