FIX: crash on invalid uri component

This commit is contained in:
Sam 2014-07-30 17:09:55 +10:00
parent 6dbd6f7428
commit 84836944e8
2 changed files with 8 additions and 1 deletions

View File

@ -263,7 +263,7 @@ module PrettyText
uri = URI(href)
site_uri ||= URI(Discourse.base_url)
link["href"] = "#{site_uri}#{link['href']}" unless uri.host.present?
rescue URI::InvalidURIError
rescue URI::InvalidURIError, URI::InvalidComponentError
# leave it
end
end

View File

@ -266,4 +266,11 @@ describe PrettyText do
end
end
describe 'format_for_email' do
it 'does not crash' do
PrettyText.format_for_email('<a href="mailto:michael.brown@discourse.org?subject=Your%20post%20at%20http://try.discourse.org/t/discussion-happens-so-much/127/1000?u=supermathie">test</a>')
end
end
end