From cb16661d365c4ec16adde6ebfc8f2817f616b7aa Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 26 Apr 2012 17:57:49 +0000 Subject: [PATCH] Removes the XML declaration that breaks the parser with JRuby. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9534 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/scm/adapters/abstract_adapter.rb | 7 +++++++ lib/redmine/scm/adapters/mercurial_adapter.rb | 6 +++--- lib/redmine/scm/adapters/subversion_adapter.rb | 8 ++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index bf512d1f1..e40d3deb2 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -267,6 +267,13 @@ module Redmine nil end end + + def parse_xml(xml) + if RUBY_PLATFORM == 'java' + xml = xml.sub(%r{<\?xml[^>]*\?>}, '') + end + ActiveSupport::XmlMini.parse(xml) + end end class Entries < Array diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index c5525f4e9..ddc81d6d8 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -135,7 +135,7 @@ module Redmine output.force_encoding('UTF-8') end begin - @summary = ActiveSupport::XmlMini.parse(output)['rhsummary'] + @summary = parse_xml(output)['rhsummary'] rescue end end @@ -151,7 +151,7 @@ module Redmine output.force_encoding('UTF-8') end begin - ActiveSupport::XmlMini.parse(output)['rhmanifest']['repository']['manifest'] + parse_xml(output)['rhmanifest']['repository']['manifest'] rescue end end @@ -199,7 +199,7 @@ module Redmine end begin # Mercurial < 1.5 does not support footer template for '' - ActiveSupport::XmlMini.parse("#{output}")['log'] + parse_xml("#{output}")['log'] rescue end end diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb index ad982dbc2..a3e642cb1 100644 --- a/lib/redmine/scm/adapters/subversion_adapter.rb +++ b/lib/redmine/scm/adapters/subversion_adapter.rb @@ -71,7 +71,7 @@ module Redmine output.force_encoding('UTF-8') end begin - doc = ActiveSupport::XmlMini.parse(output) + doc = parse_xml(output) # root_url = doc.elements["info/entry/repository/root"].text info = Info.new({:root_url => doc['info']['entry']['repository']['root']['__content__'], :lastrev => Revision.new({ @@ -103,7 +103,7 @@ module Redmine output.force_encoding('UTF-8') end begin - doc = ActiveSupport::XmlMini.parse(output) + doc = parse_xml(output) each_xml_element(doc['lists']['list'], 'entry') do |entry| commit = entry['commit'] commit_date = commit['date'] @@ -146,7 +146,7 @@ module Redmine output.force_encoding('UTF-8') end begin - doc = ActiveSupport::XmlMini.parse(output) + doc = parse_xml(output) each_xml_element(doc['properties']['target'], 'property') do |property| properties[ property['name'] ] = property['__content__'].to_s end @@ -173,7 +173,7 @@ module Redmine output.force_encoding('UTF-8') end begin - doc = ActiveSupport::XmlMini.parse(output) + doc = parse_xml(output) each_xml_element(doc['log'], 'logentry') do |logentry| paths = [] each_xml_element(logentry['paths'], 'path') do |path|