mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: Handle invalid URLs gracefully when pulling hotlinked images
This commit is contained in:
parent
78626d2832
commit
9f2e7e4651
@ -220,7 +220,7 @@ module Jobs
|
||||
uri.normalize!
|
||||
uri.scheme = nil
|
||||
uri.to_s
|
||||
rescue URI::Error
|
||||
rescue URI::Error, Addressable::URI::InvalidURIError
|
||||
src
|
||||
end
|
||||
end
|
||||
|
@ -222,6 +222,16 @@ describe Jobs::PullHotlinkedImages do
|
||||
MD
|
||||
end
|
||||
|
||||
it 'works when invalid url in post' do
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
![some test](#{image_url})
|
||||
![some test 2]("#{image_url})
|
||||
MD
|
||||
|
||||
expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
|
||||
.to change { Upload.count }.by(1)
|
||||
end
|
||||
|
||||
it 'replaces bbcode images' do
|
||||
post = Fabricate(:post, raw: <<~MD)
|
||||
[img]
|
||||
|
Loading…
Reference in New Issue
Block a user