]> cat aescling's git repositories - mastodon.git/commitdiff
Fix an error when TagManager.local_url? is called with a bad URI (#3701)
authorThibG <thib@sitedethib.com>
Sun, 11 Jun 2017 20:53:12 +0000 (22:53 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 11 Jun 2017 20:53:12 +0000 (22:53 +0200)
TagManager.local_url? was sometimes called with an URI with a nil host,
leading to a crash in TagManager.local_url?. This fixes moves the
already-existing uri.host.blank? check in front to avoid this case.

app/services/fetch_link_card_service.rb

index ec9b5226e82833596fc32a33952b6ef2839f8f5b..c2df7b2f016d018c8ac67d3ef9be4de0c18a5d22 100644 (file)
@@ -36,7 +36,7 @@ class FetchLinkCardService < BaseService
 
   def bad_url?(uri)
     # Avoid local instance URLs and invalid URLs
-    TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme) || uri.host.blank?
+    uri.host.blank? || TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme)
   end
 
   def skip_link?(a)