A platform for community discussion. Free, open, simple.
FIX: Handle invalid URLs gracefully when pulling hotlinked images
David Taylor9f2e7e465149
diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rbindex 80367f4f51c..415ce3b569c 100644--- a/app/jobs/regular/pull_hotlinked_images.rb+++ b/app/jobs/regular/pull_hotlinked_images.rb@@ -220,7 +220,7 @@ module Jobsuri.normalize!uri.scheme = niluri.to_s- rescue URI::Error+ rescue URI::Error, Addressable::URI::InvalidURIErrorsrcendenddiff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rbindex 37499a81e0f..b5893830046 100644--- a/spec/jobs/pull_hotlinked_images_spec.rb+++ b/spec/jobs/pull_hotlinked_images_spec.rb@@ -222,6 +222,16 @@ describe Jobs::PullHotlinkedImages doMDend+ it 'works when invalid url in post' do+ post = Fabricate(:post, raw: <<~MD)+ + + MD++ expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }+ .to change { Upload.count }.by(1)+ end+it 'replaces bbcode images' dopost = Fabricate(:post, raw: <<~MD)[img]