FIX: don't break when posting invalid URIs

This commit is contained in:
Régis Hanol 2018-04-19 12:29:35 +02:00
parent 74b812593c
commit 45850a0cd6
2 changed files with 9 additions and 1 deletions

View File

@ -118,7 +118,7 @@ SQL
.map do |u|
uri = begin
URI.parse(u.url)
rescue URI::InvalidURIError
rescue URI::Error
end
[u, uri]

View File

@ -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]") }