Commit 110f5a16 authored by Douwe Maan's avatar Douwe Maan

Catch all URI errors in ExternalLinkFilter

parent b46b52af
---
title: Catch all URI errors in ExternalLinkFilter
merge_request:
author:
...@@ -24,7 +24,7 @@ module Banzai ...@@ -24,7 +24,7 @@ module Banzai
def uri(href) def uri(href)
URI.parse(href) URI.parse(href)
rescue URI::InvalidURIError rescue URI::Error
nil nil
end end
......
...@@ -55,6 +55,13 @@ describe Banzai::Filter::ExternalLinkFilter, lib: true do ...@@ -55,6 +55,13 @@ describe Banzai::Filter::ExternalLinkFilter, lib: true do
expect(doc.to_html).to eq(expected) expect(doc.to_html).to eq(expected)
end end
it 'skips improperly formatted mailtos' do
doc = filter %q(<p><a href="mailto://jblogs@example.com">Email</a></p>)
expected = %q(<p><a href="mailto://jblogs@example.com">Email</a></p>)
expect(doc.to_html).to eq(expected)
end
end end
context 'for links with a username' do context 'for links with a username' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment