A platform for community discussion. Free, open, simple.
FIX: Replace onebox markdown when pulling hotlinked image (#17328)
David Taylor78e03649abbb
diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rbindex b2519f6331f..3cc45a6b5a9 100644--- a/app/services/inline_uploads.rb+++ b/app/services/inline_uploads.rb@@ -245,6 +245,14 @@ class InlineUploads# Markdown inline - InlineUploads.match_md_inline_img(raw, external_src: true, &replace)+ raw.gsub!(/^(https?:\/\/\S+)(\s?)$/) do |match|+ if upload = blk.call(match)+ ""+ else+ match+ end+ end+rawenddiff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rbindex 3e6cc6088b7..3de3afc1c83 100644--- a/spec/jobs/pull_hotlinked_images_spec.rb+++ b/spec/jobs/pull_hotlinked_images_spec.rb@@ -350,6 +350,7 @@ describe Jobs::PullHotlinkedImages dobefore dostub_request(:head, url)stub_request(:get, url).to_return(body: '')+ stub_request(:head, image_url)stub_request(:get, api_url).to_return(body: "{\"query\": {@@ -399,6 +400,7 @@ describe Jobs::PullHotlinkedImages do#{url}<img src='#{broken_image_url}'><a href='#{url}'><img src='#{large_image_url}'></a>+ #{image_url}MDstub_image_size@@ -413,6 +415,7 @@ describe Jobs::PullHotlinkedImages dohttps://commons.wikimedia.org/wiki/File:Brisbane_May_2013201.jpg<img src='#{broken_image_url}'><a href='#{url}'><img src='#{large_image_url}'></a>+ MDexpect(post.cooked).to match(/<p><img src=.*\/uploads/)