summaryrefslogtreecommitdiff
path: root/lib/banzai/filter/autolink_filter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/autolink_filter.rb')
-rw-r--r--lib/banzai/filter/autolink_filter.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb
index f3061bad4ff..086adf59d2b 100644
--- a/lib/banzai/filter/autolink_filter.rb
+++ b/lib/banzai/filter/autolink_filter.rb
@@ -114,7 +114,11 @@ module Banzai
# Since this came from a Text node, make sure the new href is encoded.
# `commonmarker` percent encodes the domains of links it handles, so
# do the same (instead of using `normalized_encode`).
- href_safe = Addressable::URI.encode(match).html_safe
+ begin
+ href_safe = Addressable::URI.encode(match).html_safe
+ rescue Addressable::URI::InvalidURIError
+ return uri.to_s
+ end
html_safe_match = match.html_safe
options = link_options.merge(href: href_safe)