summaryrefslogtreecommitdiff
path: root/lib/banzai/filter
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2019-02-04 10:23:27 -0600
committerBrett Walker <bwalker@gitlab.com>2019-02-22 12:13:11 -0600
commite399fb69f9188c6bfd46088cd3732f8fae0a3a90 (patch)
tree2afa21be1b54618e8148caf11ec02227bcfc6c47 /lib/banzai/filter
parentc5b5b18b3f1c5b683ceb4471e667d675de9200eb (diff)
downloadgitlab-ce-e399fb69f9188c6bfd46088cd3732f8fae0a3a90.tar.gz
Catch possible Addressable::URI::InvalidURIError
Diffstat (limited to 'lib/banzai/filter')
-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)