Skip to content
Snippets Groups Projects
Commit 1cfc4af3 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch 'rs-dev-issue-2550' into 'master'

Remove trailing HTML entities from non-Rinku autolinks as well.

Addresses internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2550

See merge request !1179
parents d0d435a2 747fe752
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
@@ -87,8 +87,14 @@ module Gitlab
Loading
@@ -87,8 +87,14 @@ module Gitlab
   
def autolink_filter(text) def autolink_filter(text)
text.gsub(LINK_PATTERN) do |match| text.gsub(LINK_PATTERN) do |match|
# Remove any trailing HTML entities and store them for appending
# outside the link element. The entity must be marked HTML safe in
# order to be output literally rather than escaped.
match.gsub!(/((?:&[\w#]+;)+)\z/, '')
dropped = ($1 || '').html_safe
options = link_options.merge(href: match) options = link_options.merge(href: match)
content_tag(:a, match, options) content_tag(:a, match, options) + dropped
end end
end end
   
Loading
Loading
Loading
@@ -86,6 +86,16 @@ module Gitlab::Markdown
Loading
@@ -86,6 +86,16 @@ module Gitlab::Markdown
   
doc = filter("See #{link}, ok?") doc = filter("See #{link}, ok?")
expect(doc.at_css('a').text).to eq link expect(doc.at_css('a').text).to eq link
doc = filter("See #{link}...")
expect(doc.at_css('a').text).to eq link
end
it 'does not include trailing HTML entities' do
doc = filter("See <<<#{link}>>>")
expect(doc.at_css('a')['href']).to eq link
expect(doc.text).to eq "See <<<#{link}>>>"
end end
   
it 'accepts link_attr options' do it 'accepts link_attr options' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment