Commit 8e248366 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents c4eb609c 8e38ca94
---
title: Fix potential Addressable::URI::InvalidURIError
merge_request: 24908
author:
type: fixed
......@@ -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)
......
......@@ -121,6 +121,13 @@ describe Banzai::Filter::AutolinkFilter do
expect(doc.to_s).to eq("See #{link}")
end
it 'does not autolink bad URLs after we remove trailing punctuation' do
link = 'http://]'
doc = filter("See #{link}")
expect(doc.to_s).to eq("See #{link}")
end
it 'does not include trailing punctuation' do
['.', ', ok?', '...', '?', '!', ': is that ok?'].each do |trailing_punctuation|
doc = filter("See #{link}#{trailing_punctuation}")
......
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