diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 83a3f5f7117..8e6e10002c9 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -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 diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 594257ef3cc..4becd6eb60c 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -266,4 +266,11 @@ describe PrettyText do end end + describe 'format_for_email' do + it 'does not crash' do + PrettyText.format_for_email('test') + end + end + + end