summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-01-05 15:02:24 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-01-05 15:02:24 +0000
commitad18cfda32debd5e183baf167af386d797365ffa (patch)
treeed2e9b8268da6014386bc159e221f37ed3f10674
parent6ad68ae0277c9e2a1d09d46f7b2db8dc8e1310df (diff)
downloadredmine-ad18cfda32debd5e183baf167af386d797365ffa.tar.gz
redmine-ad18cfda32debd5e183baf167af386d797365ffa.zip
scm: mercurial: escape any filenames by urlescape (#2664, #7064).
In Mercurial, filename is not UTF-8 but byte-string. So it should be escaped to UTF-8-safe string before parsing as XML document. NOTE: Mercurial's {|obfuscate} filter cannot be used here, because it treats filename as encoded by HGENCODING. Contributed by Yuya Nishihara. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4633 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/scm/adapters/mercurial/hg-template-0.9.5.tmpl8
-rw-r--r--lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl8
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb5
3 files changed, 11 insertions, 10 deletions
diff --git a/lib/redmine/scm/adapters/mercurial/hg-template-0.9.5.tmpl b/lib/redmine/scm/adapters/mercurial/hg-template-0.9.5.tmpl
index b3029e6ff..3cf584aed 100644
--- a/lib/redmine/scm/adapters/mercurial/hg-template-0.9.5.tmpl
+++ b/lib/redmine/scm/adapters/mercurial/hg-template-0.9.5.tmpl
@@ -3,10 +3,10 @@ changeset_quiet = 'This template must be used with --debug option\n'
changeset_verbose = 'This template must be used with --debug option\n'
changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodate}</date>\n<paths>\n{files}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n{tags}</logentry>\n\n'
-file = '<path action="M">{file|escape}</path>\n'
-file_add = '<path action="A">{file_add|escape}</path>\n'
-file_del = '<path action="D">{file_del|escape}</path>\n'
-file_copy = '<path-copied copyfrom-path="{source|escape}">{name|urlescape}</path-copied>\n'
+file = '<path action="M">{file|urlescape}</path>\n'
+file_add = '<path action="A">{file_add|urlescape}</path>\n'
+file_del = '<path action="D">{file_del|urlescape}</path>\n'
+file_copy = '<path-copied copyfrom-path="{source|urlescape}">{name|urlescape}</path-copied>\n'
tag = '<tag>{tag|escape}</tag>\n'
header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n'
# footer="</log>" \ No newline at end of file
diff --git a/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl b/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl
index b6cc7a786..def80c262 100644
--- a/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl
+++ b/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl
@@ -3,10 +3,10 @@ changeset_quiet = 'This template must be used with --debug option\n'
changeset_verbose = 'This template must be used with --debug option\n'
changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodatesec}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n{tags}</logentry>\n\n'
-file_mod = '<path action="M">{file_mod|escape}</path>\n'
-file_add = '<path action="A">{file_add|escape}</path>\n'
-file_del = '<path action="D">{file_del|escape}</path>\n'
-file_copy = '<path-copied copyfrom-path="{source|escape}">{name|urlescape}</path-copied>\n'
+file_mod = '<path action="M">{file_mod|urlescape}</path>\n'
+file_add = '<path action="A">{file_add|urlescape}</path>\n'
+file_del = '<path action="D">{file_del|urlescape}</path>\n'
+file_copy = '<path-copied copyfrom-path="{source|urlescape}">{name|urlescape}</path-copied>\n'
tag = '<tag>{tag|escape}</tag>\n'
header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n'
# footer="</log>"
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb
index 72dc5dd25..be755419f 100644
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine/scm/adapters/abstract_adapter'
+require 'cgi'
module Redmine
module Scm
@@ -127,8 +128,8 @@ module Redmine
from_rev = logentry.attributes['revision']
end
paths << {:action => path.attributes['action'],
- :path => "/#{path.text}",
- :from_path => from_path ? "/#{from_path}" : nil,
+ :path => "/#{CGI.unescape(path.text)}",
+ :from_path => from_path ? "/#{CGI.unescape(from_path)}" : nil,
:from_revision => from_rev ? from_rev : nil
}
end