From 54afa314fb4a2707a5e3cab536393f06c822d526 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 7 Jun 2019 13:00:52 +0100 Subject: [PATCH] FIX: Do not download emojis in pull_hotlinked_images --- app/jobs/regular/pull_hotlinked_images.rb | 5 ++++- spec/jobs/pull_hotlinked_images_spec.rb | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rb index 672b85ac965..23f69349e96 100644 --- a/app/jobs/regular/pull_hotlinked_images.rb +++ b/app/jobs/regular/pull_hotlinked_images.rb @@ -156,7 +156,10 @@ module Jobs # If file is on the forum or CDN domain if Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i - # Return true if we can't find the upload in the db + return false if src =~ /\/images\/emoji\// + + # Someone could hotlink a file from a different site on the same CDN, + # so check whether we have it in this database return !Upload.get_from_url(src) end diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb index 962699ff63d..446adea9737 100644 --- a/spec/jobs/pull_hotlinked_images_spec.rb +++ b/spec/jobs/pull_hotlinked_images_spec.rb @@ -191,6 +191,11 @@ describe Jobs::PullHotlinkedImages do expect(subject.should_download_image?(src)).to eq(true) end + it "returns false for emoji" do + src = Emoji.url_for("testemoji.png") + expect(subject.should_download_image?(src)).to eq(false) + end + it 'returns false for valid remote URLs' do expect(subject.should_download_image?("http://meta.discourse.org")).to eq(false) end