diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb index 3238f84ea15..40fbcab8010 100644 --- a/app/models/topic_link.rb +++ b/app/models/topic_link.rb @@ -118,7 +118,7 @@ SQL .map do |u| uri = begin URI.parse(u.url) - rescue URI::InvalidURIError + rescue URI::Error end [u, uri] diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb index bb9408f8081..606ba5f7bae 100644 --- a/spec/models/topic_link_spec.rb +++ b/spec/models/topic_link_spec.rb @@ -169,6 +169,14 @@ http://b.com/#{'a' * 500} end end + context "email address" do + it "does not extract a link" do + post = topic.posts.create(user: user, raw: "Valid email: foo@bar.com\n\nInvalid email: rfc822;name@domain.com") + TopicLink.extract_from(post) + expect(topic.topic_links).to be_blank + end + end + context "mail link" do let(:post) { topic.posts.create(user: user, raw: "[email]bar@example.com[/email]") }