about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2017-07-03 18:03:34 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-07-03 11:03:34 +0200
commita6d02cff368d96178b0843ef021232d2187abbcd (patch)
treefda8ab9795543b9b5e4cf562ad02a8454242f7c6 /app/models
parentbe94f9e35d4fbb1558fa772a618276562039fd96 (diff)
Rescue exceptions caused by FetchLinkCardService (#4045)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/remotable.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb
index b0077ce96..08d4fc59c 100644
--- a/app/models/concerns/remotable.rb
+++ b/app/models/concerns/remotable.rb
@@ -10,7 +10,11 @@ module Remotable
       method_name = "#{attribute_name}=".to_sym
 
       define_method method_name do |url|
-        parsed_url = Addressable::URI.parse(url).normalize
+        begin
+          parsed_url = Addressable::URI.parse(url).normalize
+        rescue Addressable::URI::InvalidURIError
+          return
+        end
 
         return if !%w(http https).include?(parsed_url.scheme) || parsed_url.host.empty? || self[attribute_name] == url
 
@@ -26,7 +30,7 @@ module Remotable
           send("#{attachment_name}_file_name=", filename)
 
           self[attribute_name] = url if has_attribute?(attribute_name)
-        rescue HTTP::TimeoutError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
+        rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
           Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
           nil
         end