mirror of
https://github.com/docusealco/docuseal
synced 2026-11-12 23:42:33 -05:00
fix url download
This commit is contained in:
1 parent
146b37f8cd
commit
5032676bd2
1 file changed
+11
-10
+11
-10
@@ -8,19 +8,20 @@ module DownloadUtils
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(url)
|
def call(url)
|
||||||
uri = Addressable::URI.parse(url)
|
uri = begin
|
||||||
|
URI(url)
|
||||||
if Docuseal.multitenant?
|
rescue URI::Error
|
||||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Only HTTPS is allowed." if uri.scheme != 'https'
|
Addressable::URI.parse(url).normalize
|
||||||
|
|
||||||
if uri.host.in?(LOCALHOSTS)
|
|
||||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Can't download from localhost."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resp = conn.get(uri.display_uri.to_s)
|
if Docuseal.multitenant?
|
||||||
|
raise UnableToDownload, "Error loading: #{uri}. Only HTTPS is allowed." if uri.scheme != 'https'
|
||||||
|
raise UnableToDownload, "Error loading: #{uri}. Can't download from localhost." if uri.host.in?(LOCALHOSTS)
|
||||||
|
end
|
||||||
|
|
||||||
raise UnableToDownload, "Error loading: #{uri.display_uri}" if resp.status >= 400
|
resp = conn.get(uri)
|
||||||
|
|
||||||
|
raise UnableToDownload, "Error loading: #{uri}" if resp.status >= 400
|
||||||
|
|
||||||
resp
|
resp
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user