diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-05-24 12:32:50 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-05-24 12:32:50 +0000 |
commit | 6b89b7cbcf1098831ffa06ea6700addba5a29ed5 (patch) | |
tree | ac49b031bd9a851f90f69c460982a4b21f36b6ca /lib | |
parent | 64d13d5a8ce70cf961e81a52b336ef5f651136e1 (diff) | |
parent | 17b97bf029a7085f6b726071a15f5d231510f1b6 (diff) | |
download | gitlab-ce-6b89b7cbcf1098831ffa06ea6700addba5a29ed5.tar.gz |
Merge branch 'fix-milestone-references-with-escaped-html-entities' into 'master'
Fix milestone references with HTML entities in the name
Closes #62114
See merge request gitlab-org/gitlab-ce!28667
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/abstract_reference_filter.rb | 8 | ||||
-rw-r--r-- | lib/banzai/filter/label_reference_filter.rb | 8 | ||||
-rw-r--r-- | lib/banzai/filter/milestone_reference_filter.rb | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb index 44b151d01e7..0224dd8fcd1 100644 --- a/lib/banzai/filter/abstract_reference_filter.rb +++ b/lib/banzai/filter/abstract_reference_filter.rb @@ -363,6 +363,14 @@ module Banzai group_ref end + + def unescape_html_entities(text) + CGI.unescapeHTML(text.to_s) + end + + def escape_html_entities(text) + CGI.escapeHTML(text.to_s) + end end end end diff --git a/lib/banzai/filter/label_reference_filter.rb b/lib/banzai/filter/label_reference_filter.rb index 4d67140b0a1..4892668fc22 100644 --- a/lib/banzai/filter/label_reference_filter.rb +++ b/lib/banzai/filter/label_reference_filter.rb @@ -104,14 +104,6 @@ module Banzai matches[:namespace] && matches[:project] end - def unescape_html_entities(text) - CGI.unescapeHTML(text.to_s) - end - - def escape_html_entities(text) - CGI.escapeHTML(text.to_s) - end - def object_link_title(object, matches) # use title of wrapped element instead nil diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb index fce042e8946..08969753d75 100644 --- a/lib/banzai/filter/milestone_reference_filter.rb +++ b/lib/banzai/filter/milestone_reference_filter.rb @@ -51,13 +51,13 @@ module Banzai # default implementation. return super(text, pattern) if pattern != Milestone.reference_pattern - text.gsub(pattern) do |match| + unescape_html_entities(text).gsub(pattern) do |match| milestone = find_milestone($~[:project], $~[:namespace], $~[:milestone_iid], $~[:milestone_name]) if milestone yield match, milestone.id, $~[:project], $~[:namespace], $~ else - match + escape_html_entities(match) end end end |