FIX: Respect protocol relative URLs in email styling
This commit is contained in:
parent
7cfb583016
commit
b7c50ecdaa
|
@ -20,7 +20,7 @@ module Email
|
|||
img['style'] = "max-width: 694px;"
|
||||
end
|
||||
|
||||
if img['src'][0] == "/"
|
||||
if img['src'] =~ /^\/[^\/]/
|
||||
img['src'] = "#{Discourse.base_url}#{img['src']}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,11 @@ describe Email::Styles do
|
|||
expect(frag.at("img")["src"]).to eq("#{Discourse.base_url}/some-image.png")
|
||||
end
|
||||
|
||||
it "it does not change protocol relative paths" do
|
||||
frag = basic_fragment("<img src='//www.discourse.com/some-image.gif'>")
|
||||
expect(frag.at("img")["src"]).to eq("//www.discourse.com/some-image.gif")
|
||||
end
|
||||
|
||||
it "strips classes and ids" do
|
||||
frag = basic_fragment("<div class='foo' id='bar'><div class='foo' id='bar'></div></div>")
|
||||
expect(frag.to_html).to eq("<div><div></div></div>")
|
||||
|
|
Loading…
Reference in New Issue