mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: s3 cdn would break cooking if <img> tag had no src
This commit is contained in:
parent
677cdbbda0
commit
b7a0a295c0
2 changed files with 4 additions and 2 deletions
|
@ -224,6 +224,7 @@ module PrettyText
|
||||||
|
|
||||||
def self.add_s3_cdn(doc)
|
def self.add_s3_cdn(doc)
|
||||||
doc.css("img").each do |img|
|
doc.css("img").each do |img|
|
||||||
|
next unless img["src"]
|
||||||
img["src"] = img["src"].sub(Discourse.store.absolute_base_url, SiteSetting.s3_cdn_url)
|
img["src"] = img["src"].sub(Discourse.store.absolute_base_url, SiteSetting.s3_cdn_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -323,8 +323,9 @@ describe PrettyText do
|
||||||
SiteSetting.s3_upload_bucket = "test"
|
SiteSetting.s3_upload_bucket = "test"
|
||||||
SiteSetting.s3_cdn_url = "https://awesome.cdn"
|
SiteSetting.s3_cdn_url = "https://awesome.cdn"
|
||||||
|
|
||||||
raw = "<img src='#{Discourse.store.absolute_base_url}/original/9/9/99c9384b8b6d87f8509f8395571bc7512ca3cad1.jpg'"
|
# add extra img tag to ensure it does not blow up
|
||||||
cooked = "<p><img src='https://awesome.cdn/original/9/9/99c9384b8b6d87f8509f8395571bc7512ca3cad1.jpg'></p>"
|
raw = "<img><img src='#{Discourse.store.absolute_base_url}/original/9/9/99c9384b8b6d87f8509f8395571bc7512ca3cad1.jpg'"
|
||||||
|
cooked = "<p><img><img src='https://awesome.cdn/original/9/9/99c9384b8b6d87f8509f8395571bc7512ca3cad1.jpg'></p>"
|
||||||
|
|
||||||
expect(PrettyText.cook(raw)).to match_html(cooked)
|
expect(PrettyText.cook(raw)).to match_html(cooked)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue