summaryrefslogtreecommitdiff
path: root/app/presenters
diff options
context:
space:
mode:
authorThiago Presa <tpresa@gitlab.com>2018-10-23 02:21:32 +0000
committerThiago Presa <tpresa@gitlab.com>2018-10-22 23:46:50 -0300
commitaca5fb4e1ba5f994578bbeab05fe60bd0d964463 (patch)
treeee5d6e8b3f80bf9f2c67c2aecbdcb8b5ab90da37 /app/presenters
parentf17e36feab266a62b316bfe88d7d558c2debaf9b (diff)
downloadgitlab-ce-aca5fb4e1ba5f994578bbeab05fe60bd0d964463.tar.gz
Merge branch 'security-11-4-51527-xss-in-mr-source-branch' into 'security-11-4'
[11.4] Fix XSS in MR source branch name See merge request gitlab/gitlabhq!2550
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/merge_request_presenter.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb
index 3f565b826dd..1db6c9eff36 100644
--- a/app/presenters/merge_request_presenter.rb
+++ b/app/presenters/merge_request_presenter.rb
@@ -108,16 +108,10 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
namespace = source_project_namespace
branch = source_branch
- if source_branch_exists?
- namespace = link_to(namespace, project_path(source_project))
- branch = link_to(branch, project_tree_path(source_project, source_branch))
- end
+ namespace_link = source_branch_exists? ? link_to(namespace, project_path(source_project)) : ERB::Util.html_escape(namespace)
+ branch_link = source_branch_exists? ? link_to(branch, project_tree_path(source_project, source_branch)) : ERB::Util.html_escape(branch)
- if for_fork?
- namespace + ":" + branch
- else
- branch
- end
+ for_fork? ? "#{namespace_link}:#{branch_link}" : branch_link
end
def closing_issues_links