diff options
-rw-r--r-- | lib/redmine/wiki_formatting/common_mark/external_links_filter.rb | 2 | ||||
-rw-r--r-- | test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb b/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb index d2ea3fafa..4c25a7b13 100644 --- a/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb +++ b/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb @@ -31,7 +31,7 @@ module Redmine next unless url next if url.starts_with?("/") || url.starts_with?("#") || !url.include?(':') - scheme = URI.parse(url).scheme + scheme = URI.parse(url).scheme rescue nil next if scheme.blank? klass = node["class"].presence diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb index fcfc3156b..d4b76c401 100644 --- a/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb @@ -44,5 +44,11 @@ if Object.const_defined?(:CommonMarker) def test_mailto_links_should_have_email_class assert_equal %(<a href="mailto:user@example.org" class="email">user</a>), filter(%(<a href="mailto:user@example.org">user</a>)) end + + def test_malformed_uri_should_not_cause_exception + assert_nothing_raised do + filter(%(<a href="http://example.com/foo#bar#">Malformed URI</a>)) + end + end end end |