From a0930b83ecfa0513990fcae8450726add1d9206d Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 16 Jul 2018 11:49:01 +0100 Subject: Escapes milestone and label names when promoting them --- spec/controllers/projects/labels_controller_spec.rb | 8 ++++++++ spec/controllers/projects/milestones_controller_spec.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb index 273702e6d21..e03d23bcdf6 100644 --- a/spec/controllers/projects/labels_controller_spec.rb +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -143,6 +143,14 @@ describe Projects::LabelsController do expect(GroupLabel.find_by(title: promoted_label_name)).not_to be_nil end + it 'renders label name without parsing it as HTML' do + label_1.update!(name: 'CCC<img src=x onerror=alert(document.domain)>') + + post :promote, namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param + + expect(flash[:notice]).to eq("CCC<img src=x onerror=alert(document.domain)> promoted to group label.") + end + context 'service raising InvalidRecord' do before do expect_any_instance_of(Labels::PromoteService).to receive(:execute) do |label| diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index e351e0fe07d..6c2d1c7e92b 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -133,7 +133,7 @@ describe Projects::MilestonesController do post :promote, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid - expect(flash[:notice]).to eq("CCC promoted to group milestone.") + expect(flash[:notice]).to eq("CCC promoted to group milestone.") end end -- cgit v1.2.1