summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejandroluis24@gmail.com>2016-04-04 23:09:44 -0300
committerAlejandro Rodríguez <alejandroluis24@gmail.com>2016-04-20 22:12:43 -0300
commit1ff896f2bf5d06d0d772fd0df98bf43edf107373 (patch)
treee8bd284dc13fdac270f05123778b8a6fe712b8a0
parent6d9794d42a7bea1150374c76fd3ce5521a44e58e (diff)
downloadgitlab-ce-1ff896f2bf5d06d0d772fd0df98bf43edf107373.tar.gz
Escaping the `object_link_text` on cross project milestone references
-rw-r--r--lib/banzai/filter/milestone_reference_filter.rb2
-rw-r--r--spec/lib/banzai/filter/milestone_reference_filter_spec.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb
index 556087c4880..aea1abf3b8e 100644
--- a/lib/banzai/filter/milestone_reference_filter.rb
+++ b/lib/banzai/filter/milestone_reference_filter.rb
@@ -39,7 +39,7 @@ module Banzai
if context[:project] == object.project
super
else
- "#{super} <i>in #{escape_once(object.project.name_with_namespace)}</i>".
+ "#{escape_once(super)} <i>in #{escape_once(object.project.name_with_namespace)}</i>".
html_safe
end
end
diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
index 26f87286b2c..ac3e6e4e536 100644
--- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
@@ -176,5 +176,11 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do
it 'contains cross project content' do
expect(result.css('a').first.text).to eq "#{milestone.name} in #{project_name}"
end
+
+ it 'escapes the name attribute' do
+ allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="})
+ doc = reference_filter("See #{reference}")
+ expect(doc.css('a').first.text).to eq "#{milestone.name} in #{project_name}"
+ end
end
end