mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Always allow downloads from CDN
This commit is contained in:
@@ -11,13 +11,14 @@ class FileHelper
|
||||
url = "https:" + url if url.start_with?("//")
|
||||
raise Discourse::InvalidParameters.new(:url) unless url =~ /^https?:\/\//
|
||||
|
||||
# uri = FinalDestination.new(url).resolve
|
||||
uri = URI.parse(url)
|
||||
uri = FinalDestination.new(url, max_redirects: follow_redirect ? 5 : 1).resolve
|
||||
return unless uri.present?
|
||||
|
||||
extension = File.extname(uri.path)
|
||||
tmp = Tempfile.new([tmp_file_name, extension])
|
||||
|
||||
File.open(tmp.path, "wb") do |f|
|
||||
downloaded = uri.open("rb", read_timeout: read_timeout, redirect: follow_redirect, allow_redirections: :all)
|
||||
downloaded = uri.open("rb", read_timeout: read_timeout)
|
||||
while f.size <= max_file_size && data = downloaded.read(512.kilobytes)
|
||||
f.write(data)
|
||||
end
|
||||
|
Reference in New Issue
Block a user