fix url download
This commit is contained in:
@@ -35,16 +35,16 @@ module DownloadUtils
|
||||
|
||||
module_function
|
||||
|
||||
def call(url)
|
||||
def call(url, validate: Docuseal.multitenant?)
|
||||
uri = begin
|
||||
URI(url)
|
||||
rescue URI::Error
|
||||
Addressable::URI.parse(url).normalize
|
||||
end
|
||||
|
||||
validate_uri!(uri) if Docuseal.multitenant?
|
||||
validate_uri!(uri) if validate
|
||||
|
||||
resp = conn.get(uri)
|
||||
resp = conn(validate:).get(uri)
|
||||
|
||||
raise UnableToDownload, "Error loading: #{uri}" if resp.status >= 400
|
||||
|
||||
@@ -56,10 +56,10 @@ module DownloadUtils
|
||||
raise UnableToDownload, "Error loading: #{uri}. Can't download from localhost." if uri.host.in?(LOCALHOSTS)
|
||||
end
|
||||
|
||||
def conn
|
||||
def conn(validate: Docuseal.multitenant?)
|
||||
Faraday.new do |faraday|
|
||||
faraday.response :follow_redirects, callback: lambda { |_, new_env|
|
||||
validate_uri!(new_env[:url]) if Docuseal.multitenant?
|
||||
validate_uri!(new_env[:url]) if validate
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -236,7 +236,7 @@ module Submitters
|
||||
|
||||
return blob if blob
|
||||
|
||||
data = DownloadUtils.call(url).body
|
||||
data = DownloadUtils.call(url, validate: true).body
|
||||
|
||||
checksum = Digest::MD5.base64digest(data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user