scm: Ruby 1.9 compatibility for XML UTF-8 parsing.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4993 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-03-03 05:51:46 +00:00 committed by Eric Davis
parent ce01f49ca7
commit ac227939ad
2 changed files with 27 additions and 3 deletions

View File

@ -120,8 +120,12 @@ module Redmine
def summary
return @summary if @summary
hg 'rhsummary' do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
@summary = ActiveSupport::XmlMini.parse(io.read)['rhsummary']
@summary = ActiveSupport::XmlMini.parse(output)['rhsummary']
rescue
end
end
@ -132,8 +136,12 @@ module Redmine
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)),
CGI.escape(without_leading_slash(p1.to_s))) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
ActiveSupport::XmlMini.parse(io.read)['rhmanifest']['repository']['manifest']
ActiveSupport::XmlMini.parse(output)['rhmanifest']['repository']['manifest']
rescue
end
end
@ -175,9 +183,13 @@ module Redmine
hg_args << '--limit' << options[:limit] if options[:limit]
hg_args << hgtarget(path) unless path.blank?
log = hg(*hg_args) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
# Mercurial < 1.5 does not support footer template for '</log>'
ActiveSupport::XmlMini.parse("#{io.read}</log>")['log']
ActiveSupport::XmlMini.parse("#{output}</log>")['log']
rescue
end
end

View File

@ -65,6 +65,9 @@ module Redmine
info = nil
shellout(cmd) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
doc = ActiveSupport::XmlMini.parse(output)
#root_url = doc.elements["info/entry/repository/root"].text
@ -94,6 +97,9 @@ module Redmine
cmd << credentials_string
shellout(cmd) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
doc = ActiveSupport::XmlMini.parse(output)
each_xml_element(doc['lists']['list'], 'entry') do |entry|
@ -134,6 +140,9 @@ module Redmine
properties = {}
shellout(cmd) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
doc = ActiveSupport::XmlMini.parse(output)
each_xml_element(doc['properties']['target'], 'property') do |property|
@ -158,6 +167,9 @@ module Redmine
cmd << ' ' + target(path)
shellout(cmd) do |io|
output = io.read
if output.respond_to?(:force_encoding)
output.force_encoding('UTF-8')
end
begin
doc = ActiveSupport::XmlMini.parse(output)
each_xml_element(doc['log'], 'logentry') do |logentry|