From 53ae431867cbb5f8c49f6123dcae530ee472ee71 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 22 Feb 2017 19:55:14 +0100 Subject: [PATCH] Skip remote media URLs that don't have a hostname --- app/models/account.rb | 2 +- app/services/process_feed_service.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/account.rb b/app/models/account.rb index ed5c461974..469695acd7 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -138,7 +138,7 @@ class Account < ApplicationRecord def avatar_remote_url=(url) parsed_url = URI.parse(url) - return if !%w(http https).include?(parsed_url.scheme) || self[:avatar_remote_url] == url + return if !%w(http https).include?(parsed_url.scheme) || parsed_url.host.empty? || self[:avatar_remote_url] == url self.avatar = parsed_url self[:avatar_remote_url] = url diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index f0a62aa14e..5d952df6fd 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -181,6 +181,9 @@ class ProcessFeedService < BaseService next unless link['href'] media = MediaAttachment.where(status: parent, remote_url: link['href']).first_or_initialize(account: parent.account, status: parent, remote_url: link['href']) + parsed_url = URI.parse(link['href']) + + next if !%w(http https).include?(parsed_url.scheme) || parsed_url.host.empty? begin media.file_remote_url = link['href']