summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-21 18:48:18 +0000
committerDouwe Maan <douwe@gitlab.com>2015-08-21 18:48:18 +0000
commit1cfc4af31e01c59066e5194a080f49ac6cacc0a3 (patch)
treee69d5c401d630fbbcd8d86a3c0e43f7a61da8da9 /lib
parentd0d435a22eea7e40d09c10b0e53032b299d6edfe (diff)
parent747fe7520b244a324b60049cbe22c22a5df29c82 (diff)
downloadgitlab-ce-1cfc4af31e01c59066e5194a080f49ac6cacc0a3.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/autolink_filter.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/markdown/autolink_filter.rb b/lib/gitlab/markdown/autolink_filter.rb
index 4e14a048cfb..541f1d88ffc 100644
--- a/lib/gitlab/markdown/autolink_filter.rb
+++ b/lib/gitlab/markdown/autolink_filter.rb
@@ -87,8 +87,14 @@ module Gitlab
def autolink_filter(text)
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)
- content_tag(:a, match, options)
+ content_tag(:a, match, options) + dropped
end
end