Add exceptions for remaing cases where XML::Parser.string is used, to catch for empty strings.

See also r14241
This commit is contained in:
Thomas Wood 2009-04-09 22:37:43 +00:00
parent 9c0f288bb7
commit 6442208841
3 changed files with 8 additions and 2 deletions

View file

@ -114,6 +114,8 @@ class ChangesetController < ApplicationController
render :nothing => true, :status => :method_not_allowed
end
rescue LibXML::XML::Error, ArgumentError => ex
raise OSM::APIBadXMLError.new("osm", xml, ex.message)
rescue ActiveRecord::RecordNotFound
render :nothing => true, :status => :not_found
rescue OSM::APIError => ex

View file

@ -52,7 +52,11 @@ class UserPreferenceController < ApplicationController
# update the entire set of preferences
def update
p = XML::Parser.string(request.raw_post)
do
p = XML::Parser.string(request.raw_post)
rescue LibXML::XML::Error, ArgumentError => ex
raise OSM::APIBadXMLError.new("preferences", xml, ex.message)
end
doc = p.parse
prefs = []

View file

@ -70,7 +70,7 @@ class Node < ActiveRecord::Base
doc.find('//osm/node').each do |pt|
return Node.from_xml_node(pt, create)
end
rescue LibXML::XML::Error => ex
rescue LibXML::XML::Error, ArgumentError => ex
raise OSM::APIBadXMLError.new("node", xml, ex.message)
end
end