diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2018-10-12 16:39:13 -0500 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2018-10-12 16:58:08 -0500 |
commit | 2f4afe45525f6536c808d46249d7557ea14de7e8 (patch) | |
tree | 714642380e5ffbc6ba8065e9fa50e4bfa009ee93 /spec/presenters | |
parent | 1103f589f0a77bf11ca3103165fb287a6d092eb5 (diff) | |
download | gitlab-ce-2f4afe45525f6536c808d46249d7557ea14de7e8.tar.gz |
Fix XSS in MR source branch name
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/merge_request_presenter_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index a1b52d8692d..bafcddebbb7 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -403,6 +403,15 @@ describe MergeRequestPresenter do is_expected .to eq("<a href=\"/#{resource.source_project.full_path}/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") end + + it 'escapes html, when source_branch does not exist' do + xss_attempt = "<img src='x' onerror=alert('bad stuff') />" + + allow(resource).to receive(:source_branch) { xss_attempt } + allow(resource).to receive(:source_branch_exists?) { false } + + is_expected.to eq(ERB::Util.html_escape(xss_attempt)) + end end describe '#rebase_path' do |