FIX: returns false if the upload url is an invalid mailto link (#9877)

FIX: returns false if the upload url is an invalid mailto link (#9877)

diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb
index f42fa73..5007b74 100644
--- a/lib/file_store/s3_store.rb
+++ b/lib/file_store/s3_store.rb
@@ -81,7 +81,7 @@ module FileStore
 
       begin
         parsed_url = URI.parse(URI.encode(url))
-      rescue URI::InvalidURIError
+      rescue URI::InvalidURIError, URI::InvalidComponentError
         return false
       end
 
diff --git a/spec/multisite/s3_store_spec.rb b/spec/multisite/s3_store_spec.rb
index 064c699..5681a1d 100644
--- a/spec/multisite/s3_store_spec.rb
+++ b/spec/multisite/s3_store_spec.rb
@@ -259,5 +259,11 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
       url = "https://www.someotherhostname.com/test/original/2X/d/dd7964f5fd13e1103c5244ca30abe1936c0a4b88.png"
       expect(store.has_been_uploaded?(url)).to eq(true)
     end
+
+    it "returns false if the URI is an invalid mailto link" do
+      link = 'mailto: roman;@test.com'
+
+      expect(store.has_been_uploaded?(link)).to eq(false)
+    end
   end
 end

GitHub sha: b61a291c

1 Like

This commit appears in #9877 which was approved by eviltrout. It was merged by romanrizzi.