]> cat aescling's git repositories - mastodon.git/commitdiff
Return false if object does not respond to url (#5988)
authorRenato "Lond" Cerqueira <renato@lond.com.br>
Tue, 12 Dec 2017 14:12:09 +0000 (15:12 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 12 Dec 2017 14:12:09 +0000 (15:12 +0100)
Avoid error when the service returns a mostly valid oembed, but has no
url in it, causing a MethodError: undefined method `url'
for #<OEmbed::Response::Photo:0x000056505def9620>

app/services/fetch_link_card_service.rb

index 7f4518ea7f75b44e00709f429aa5915860ee6dbe..9f0c7385824ff07f8a88219439cbb28267a48d33 100644 (file)
@@ -87,6 +87,7 @@ class FetchLinkCardService < BaseService
     when 'link'
       @card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url)
     when 'photo'
+      return false unless response.respond_to?(:url)
       @card.embed_url = response.url
       @card.width     = response.width.presence  || 0
       @card.height    = response.height.presence || 0