mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Handle img src starting with "//" in pull_hotlinked_images job
This commit is contained in:
28
spec/jobs/pull_hotlinked_images_spec.rb
Normal file
28
spec/jobs/pull_hotlinked_images_spec.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require 'rails_helper'
|
||||
require 'jobs/regular/pull_hotlinked_images'
|
||||
|
||||
describe Jobs::PullHotlinkedImages do
|
||||
|
||||
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
||||
FakeWeb.register_uri(:get, "http://wiki.mozilla.org/images/2/2e/Longcat1.png", body: png)
|
||||
SiteSetting.download_remote_images_to_local = true
|
||||
|
||||
it 'replaces image src' do
|
||||
post = Fabricate(:post, raw: "<img src='http://wiki.mozilla.org/images/2/2e/Longcat1.png'>")
|
||||
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
post.reload
|
||||
|
||||
expect(post.raw).to match(/^<img src='\/uploads/)
|
||||
end
|
||||
|
||||
it 'replaces image src without protocol' do
|
||||
post = Fabricate(:post, raw: "<img src='//wiki.mozilla.org/images/2/2e/Longcat1.png'>")
|
||||
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
post.reload
|
||||
|
||||
expect(post.raw).to match(/^<img src='\/uploads/)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user