]> source.dussan.org Git - redmine.git/commitdiff
Merged r21558 and r21559 to 5.0-stable (#36958).
authorMarius Balteanu <marius.balteanu@zitec.com>
Wed, 11 May 2022 20:31:07 +0000 (20:31 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Wed, 11 May 2022 20:31:07 +0000 (20:31 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21570 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/common_mark/external_links_filter.rb
test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb

index d2ea3fafacdef3a0e608c21e77c64ad88af30e4f..4c25a7b133981679fb096a4b58712dcbaaeb0ace 100644 (file)
@@ -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
index fcfc3156b23d65edfcaa648eccff7cd65f484011..d4b76c401c6c28cdf648725cb787779fd8cab1ea 100644 (file)
@@ -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