mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 19:15:42 +08:00
FIX: Replace onebox markdown when pulling hotlinked image (#17328)
If an image is oneboxed directly, then we should replace the onebox URL with a markdown image tag. This ensures that the wrapper link points to the downloaded version rather than the original. This regressed in bf6f8299
This commit is contained in:
parent
4730858598
commit
78e03649ab
@ -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
|
||||
|
||||
raw
|
||||
end
|
||||
|
||||
|
@ -350,6 +350,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
before do
|
||||
stub_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}
|
||||
MD
|
||||
stub_image_size
|
||||
|
||||
@ -413,6 +415,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
https://commons.wikimedia.org/wiki/File:Brisbane_May_2013201.jpg
|
||||
<img src='#{broken_image_url}'>
|
||||
<a href='#{url}'><img src='#{large_image_url}'></a>
|
||||

|
||||
MD
|
||||
|
||||
expect(post.cooked).to match(/<p><img src=.*\/uploads/)
|
||||
|
Loading…
x
Reference in New Issue
Block a user