FIX: Do not download emojis in pull_hotlinked_images

This commit is contained in:
David Taylor 2019-06-07 13:00:52 +01:00
parent fce34aa799
commit 54afa314fb
2 changed files with 9 additions and 1 deletions

View File

@ -156,7 +156,10 @@ module Jobs
# If file is on the forum or CDN domain # If file is on the forum or CDN domain
if Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i 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) return !Upload.get_from_url(src)
end end

View File

@ -191,6 +191,11 @@ describe Jobs::PullHotlinkedImages do
expect(subject.should_download_image?(src)).to eq(true) expect(subject.should_download_image?(src)).to eq(true)
end 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 it 'returns false for valid remote URLs' do
expect(subject.should_download_image?("http://meta.discourse.org")).to eq(false) expect(subject.should_download_image?("http://meta.discourse.org")).to eq(false)
end end