A platform for community discussion. Free, open, simple.
FIX: handle invalid mailto links
Arpit Jalan290ee312e673
diff --git a/app/models/upload.rb b/app/models/upload.rbindex a9907954922..754e5d7f69a 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -85,7 +85,7 @@ class Upload < ActiveRecord::Base# always try to get the pathuri = beginURI(URI.unescape(url))- rescue URI::InvalidURIError+ rescue URI::InvalidURIError, URI::InvalidComponentErrorendurl = uri.path if uri.try(:scheme)diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rbindex a7c0d4ab0e8..32b86bbc182 100644--- a/spec/models/upload_spec.rb+++ b/spec/models/upload_spec.rb@@ -88,6 +88,7 @@ describe Upload doit "doesn't blow up with an invalid URI" doexpect { Upload.get_from_url("http://ip:port/index.html") }.not_to raise_errorexpect { Upload.get_from_url("mailto:admin%40example.com") }.not_to raise_error+ expect { Upload.get_from_url("mailto:example") }.not_to raise_errorenddescribe "s3 store" do