diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-03-03 05:51:46 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-03-03 05:51:46 +0000 |
commit | 923558e45c11184d50be70ca12702dd7a54662ea (patch) | |
tree | 2ebdee0dec2c8ac07ec137311b119fed7c778c52 /lib/redmine/scm | |
parent | 71aac2e3fe47ceeafa1c6a50aa8025093af4d33f (diff) | |
download | redmine-923558e45c11184d50be70ca12702dd7a54662ea.tar.gz redmine-923558e45c11184d50be70ca12702dd7a54662ea.zip |
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
Diffstat (limited to 'lib/redmine/scm')
-rw-r--r-- | lib/redmine/scm/adapters/mercurial_adapter.rb | 18 | ||||
-rw-r--r-- | lib/redmine/scm/adapters/subversion_adapter.rb | 12 |
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index a0f1db195..1f9153fab 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -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 diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb index 1fad6e3fa..59f577e64 100644 --- a/lib/redmine/scm/adapters/subversion_adapter.rb +++ b/lib/redmine/scm/adapters/subversion_adapter.rb @@ -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|
|