From 45c8e9e03aabcd06057d784f3fb129026543d659 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 8 May 2020 12:25:48 +0000 Subject: scm: mercurial: escape branch and tag names (#27790) git-svn-id: http://svn.redmine.org/redmine/trunk@19765 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/scm/adapters/mercurial/redminehelper.py | 4 ++-- lib/redmine/scm/adapters/mercurial_adapter.rb | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/redmine/scm/adapters/mercurial/redminehelper.py b/lib/redmine/scm/adapters/mercurial/redminehelper.py index 8097d905a..c187df8c2 100644 --- a/lib/redmine/scm/adapters/mercurial/redminehelper.py +++ b/lib/redmine/scm/adapters/mercurial/redminehelper.py @@ -85,7 +85,7 @@ def _tags(ui, repo): except error.LookupError: continue ui.write('\n' - % (r, _x(node.hex(n)), _x(t))) + % (r, _x(node.hex(n)), _u(t))) def _branches(ui, repo): # see mercurial/commands.py:branches @@ -110,7 +110,7 @@ def _branches(ui, repo): for t, n, r in sorted(iterbranches(), key=lambda e: e[2], reverse=True): if lookup(r, n) in branchheads(t): ui.write('\n' - % (r, _x(node.hex(n)), _x(t))) + % (r, _x(node.hex(n)), _u(t))) def _manifest(ui, repo, path, rev): ctx = _changectx(repo, rev) diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index f07bf0cfc..a81763c5b 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -97,21 +97,22 @@ module Redmine end def tags - as_ary(summary['repository']['tag']).map { |e| e['name'] } + as_ary(summary['repository']['tag']).map {|e| CGI.unescape(e['name'])} end # Returns map of {'tag' => 'nodeid', ...} def tagmap - alist = as_ary(summary['repository']['tag']).map do |e| - e.values_at('name', 'node') + map = {} + as_ary(summary['repository']['tag']).each do |e| + map[CGI.unescape(e['name'])] = e['node'] end - Hash[*alist.flatten] + map end def branches brs = [] as_ary(summary['repository']['branch']).each do |e| - br = Branch.new(e['name']) + br = Branch.new(CGI.unescape(e['name'])) br.revision = e['revision'] br.scmid = e['node'] brs << br @@ -121,10 +122,11 @@ module Redmine # Returns map of {'branch' => 'nodeid', ...} def branchmap - alist = as_ary(summary['repository']['branch']).map do |e| - e.values_at('name', 'node') + map = {} + branches.each do |b| + map[b.to_s] = b.scmid end - Hash[*alist.flatten] + map end def summary -- cgit v1.2.3