mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: broken mailto href's in emails
This commit is contained in:
parent
d96c775833
commit
b8cf0788c6
@ -360,7 +360,9 @@ module PrettyText
|
|||||||
begin
|
begin
|
||||||
uri = URI(href)
|
uri = URI(href)
|
||||||
site_uri ||= URI(Discourse.base_url)
|
site_uri ||= URI(Discourse.base_url)
|
||||||
link["href"] = "#{site_uri}#{link['href']}" unless uri.host.present?
|
unless uri.host.present? || href.start_with?('mailto')
|
||||||
|
link["href"] = "#{site_uri}#{link['href']}"
|
||||||
|
end
|
||||||
rescue URI::InvalidURIError, URI::InvalidComponentError
|
rescue URI::InvalidURIError, URI::InvalidComponentError
|
||||||
# leave it
|
# leave it
|
||||||
end
|
end
|
||||||
|
@ -628,6 +628,11 @@ describe PrettyText do
|
|||||||
html = "<p>Check out <a href=\"not a real url\">this guy</a>.</p>"
|
html = "<p>Check out <a href=\"not a real url\">this guy</a>.</p>"
|
||||||
expect { described_class.format_for_email(html, post) }.to_not raise_error
|
expect { described_class.format_for_email(html, post) }.to_not raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't change mailto" do
|
||||||
|
html = "<p>Contact me at <a href=\"mailto:username@me.com\">this address</a>.</p>"
|
||||||
|
expect(PrettyText.format_for_email(html, post)).to eq(html)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Is smart about linebreaks and IMG tags' do
|
it 'Is smart about linebreaks and IMG tags' do
|
||||||
|
Loading…
Reference in New Issue
Block a user