FIX: don't 💥 with an invalid URI
This commit is contained in:
parent
9457b03da1
commit
8d48779b5c
|
@ -232,9 +232,8 @@ class Upload < ActiveRecord::Base
|
|||
url = url.sub(SiteSetting.s3_cdn_url, Discourse.store.absolute_base_url) if SiteSetting.s3_cdn_url.present?
|
||||
|
||||
# always try to get the path
|
||||
if (uri = URI(url)).scheme
|
||||
url = uri.path
|
||||
end
|
||||
uri = URI(url) rescue nil
|
||||
url = uri.path if uri.try(:scheme)
|
||||
|
||||
Upload.find_by(url: url)
|
||||
end
|
||||
|
|
|
@ -149,6 +149,10 @@ describe Upload do
|
|||
)).to eq(upload)
|
||||
end
|
||||
|
||||
it "doesn't blow up with an invalid URI" do
|
||||
expect { Upload.get_from_url("http://ip:port/index.html") }.not_to raise_error
|
||||
end
|
||||
|
||||
describe "s3 store" do
|
||||
let(:path) { "/original/3X/1/0/10f73034616a796dfd70177dc54b6def44c4ba6f.png" }
|
||||
let(:url) { "//#{SiteSetting.s3_upload_bucket}.s3.amazonaws.com#{path}" }
|
||||
|
|
Loading…
Reference in New Issue