summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-08-26 07:42:52 +0000
committerGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-08-26 07:42:52 +0000
commit5a0f463ec009b049814406409e66f018fb536b90 (patch)
tree6cd556b65b3d6a0b032277bb4573b3e5db93e93b /spec
parent56a6ead22f62099b24270bb694a65e196834ba6f (diff)
parent5bfd913736eb7603630cd7af79adf2214ab50109 (diff)
downloadgitlab-ce-5a0f463ec009b049814406409e66f018fb536b90.tar.gz
Merge branch 'security-fix-html-injection-for-label-description-ce-12-1' into '12-1-stable'
Fix HTML injection for label description See merge request gitlab/gitlabhq!3298
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/labels_helper_spec.rb10
-rw-r--r--spec/models/label_spec.rb7
2 files changed, 17 insertions, 0 deletions
diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb
index 314305d7a8e..5892113c4d8 100644
--- a/spec/helpers/labels_helper_spec.rb
+++ b/spec/helpers/labels_helper_spec.rb
@@ -296,4 +296,14 @@ describe LabelsHelper do
it { is_expected.to eq('Subscribe at group level') }
end
end
+
+ describe '#label_tooltip_title' do
+ let(:html) { '<img src="example.png">This is an image</img>' }
+ let(:label_with_html_content) { create(:label, title: 'test', description: html) }
+
+ it 'removes HTML' do
+ tooltip = label_tooltip_title(label_with_html_content)
+ expect(tooltip).to eq('This is an image')
+ end
+ end
end
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 5174c590a10..c182e693ca7 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -84,6 +84,13 @@ describe Label do
end
end
+ describe '#description' do
+ it 'sanitizes description' do
+ label = described_class.new(description: '<b>foo & bar?</b>')
+ expect(label.description).to eq('foo & bar?')
+ end
+ end
+
describe 'priorization' do
subject(:label) { create(:label) }