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
This commit is contained in:
Jean-Philippe Lang 2012-04-26 17:57:49 +00:00
parent 8d73ddf73f
commit cb16661d36
3 changed files with 14 additions and 7 deletions

View File

@ -267,6 +267,13 @@ module Redmine
nil nil
end end
end end
def parse_xml(xml)
if RUBY_PLATFORM == 'java'
xml = xml.sub(%r{<\?xml[^>]*\?>}, '')
end
ActiveSupport::XmlMini.parse(xml)
end
end end
class Entries < Array class Entries < Array

View File

@ -135,7 +135,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
@summary = ActiveSupport::XmlMini.parse(output)['rhsummary'] @summary = parse_xml(output)['rhsummary']
rescue rescue
end end
end end
@ -151,7 +151,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
ActiveSupport::XmlMini.parse(output)['rhmanifest']['repository']['manifest'] parse_xml(output)['rhmanifest']['repository']['manifest']
rescue rescue
end end
end end
@ -199,7 +199,7 @@ module Redmine
end end
begin begin
# Mercurial < 1.5 does not support footer template for '</log>' # Mercurial < 1.5 does not support footer template for '</log>'
ActiveSupport::XmlMini.parse("#{output}</log>")['log'] parse_xml("#{output}</log>")['log']
rescue rescue
end end
end end

View File

@ -71,7 +71,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
doc = ActiveSupport::XmlMini.parse(output) doc = parse_xml(output)
# root_url = doc.elements["info/entry/repository/root"].text # root_url = doc.elements["info/entry/repository/root"].text
info = Info.new({:root_url => doc['info']['entry']['repository']['root']['__content__'], info = Info.new({:root_url => doc['info']['entry']['repository']['root']['__content__'],
:lastrev => Revision.new({ :lastrev => Revision.new({
@ -103,7 +103,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
doc = ActiveSupport::XmlMini.parse(output) doc = parse_xml(output)
each_xml_element(doc['lists']['list'], 'entry') do |entry| each_xml_element(doc['lists']['list'], 'entry') do |entry|
commit = entry['commit'] commit = entry['commit']
commit_date = commit['date'] commit_date = commit['date']
@ -146,7 +146,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
doc = ActiveSupport::XmlMini.parse(output) doc = parse_xml(output)
each_xml_element(doc['properties']['target'], 'property') do |property| each_xml_element(doc['properties']['target'], 'property') do |property|
properties[ property['name'] ] = property['__content__'].to_s properties[ property['name'] ] = property['__content__'].to_s
end end
@ -173,7 +173,7 @@ module Redmine
output.force_encoding('UTF-8') output.force_encoding('UTF-8')
end end
begin begin
doc = ActiveSupport::XmlMini.parse(output) doc = parse_xml(output)
each_xml_element(doc['log'], 'logentry') do |logentry| each_xml_element(doc['log'], 'logentry') do |logentry|
paths = [] paths = []
each_xml_element(logentry['paths'], 'path') do |path| each_xml_element(logentry['paths'], 'path') do |path|