From 84836944e85c64a6cc965ccc1d3fe0b08462659c Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 30 Jul 2014 17:09:55 +1000 Subject: [PATCH] FIX: crash on invalid uri component --- lib/pretty_text.rb | 2 +- spec/components/pretty_text_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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