From: Tom Hughes Date: Sun, 8 Mar 2009 11:34:46 +0000 (+0000) Subject: Update to use libxml 1.0.0 gem. X-Git-Tag: live~7626 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/07c1cd6b983d5138c1a217a716248b9a1010b9e3?ds=sidebyside Update to use libxml 1.0.0 gem. --- diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 6b36b41ae..7a0a45fc8 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -54,7 +54,7 @@ class ApiController < ApplicationController points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => TRACEPOINTS_PER_PAGE, :order => "timestamp DESC" ) doc = XML::Document.new - doc.encoding = 'UTF-8' + doc.encoding = XML::Encoding::UTF_8 root = XML::Node.new 'gpx' root['version'] = '1.0' root['creator'] = 'OpenStreetMap.org' diff --git a/app/models/node.rb b/app/models/node.rb index cec755f47..af88a117d 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -57,8 +57,7 @@ class Node < ActiveRecord::Base # Read in xml as text and return it's Node object representation def self.from_xml(xml, create=false) begin - p = XML::Parser.new - p.string = xml + p = XML::Parser.string(xml) doc = p.parse node = Node.new diff --git a/app/models/relation.rb b/app/models/relation.rb index c8516b58a..d9dba303f 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -15,8 +15,7 @@ class Relation < ActiveRecord::Base def self.from_xml(xml, create=false) begin - p = XML::Parser.new - p.string = xml + p = XML::Parser.string(xml) doc = p.parse relation = Relation.new diff --git a/app/models/way.rb b/app/models/way.rb index 958944200..6c3ea9e46 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -17,8 +17,7 @@ class Way < ActiveRecord::Base def self.from_xml(xml, create=false) begin - p = XML::Parser.new - p.string = xml + p = XML::Parser.string(xml) doc = p.parse way = Way.new diff --git a/config/initializers/libxml.rb b/config/initializers/libxml.rb index a1870dbab..f783cda1e 100644 --- a/config/initializers/libxml.rb +++ b/config/initializers/libxml.rb @@ -1,7 +1,9 @@ require 'rubygems' -gem 'libxml-ruby', '>= 0.8.3' +gem 'libxml-ruby', '>= 1.0.0' require 'libxml' -LibXML::XML::Parser.register_error_handler do |message| +# This is required otherwise libxml writes out memory errors to +# the standard output and exits uncleanly +LibXML::XML::Error.set_handler do |message| raise message end diff --git a/lib/osm.rb b/lib/osm.rb index 9c271607d..365ddf68e 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -101,7 +101,7 @@ module OSM class GeoRSS def initialize(feed_title='OpenStreetMap GPS Traces', feed_description='OpenStreetMap GPS Traces', feed_url='http://www.openstreetmap.org/traces/') @doc = XML::Document.new - @doc.encoding = 'UTF-8' + @doc.encoding = XML::Encoding::UTF_8 rss = XML::Node.new 'rss' @doc.root = rss @@ -187,7 +187,7 @@ module OSM class API def get_xml_doc doc = XML::Document.new - doc.encoding = 'UTF-8' + doc.encoding = XML::Encoding::UTF_8 root = XML::Node.new 'osm' root['version'] = API_VERSION root['generator'] = 'OpenStreetMap server'