From 644220884100abdac9be5afdfeea7d94cb774c97 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 9 Apr 2009 22:37:43 +0000 Subject: [PATCH] Add exceptions for remaing cases where XML::Parser.string is used, to catch for empty strings. See also r14241 --- app/controllers/changeset_controller.rb | 2 ++ app/controllers/user_preference_controller.rb | 6 +++++- app/models/node.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index e88387a76..bba012a9c 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -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 diff --git a/app/controllers/user_preference_controller.rb b/app/controllers/user_preference_controller.rb index 68ea88eea..b07f4ecc5 100644 --- a/app/controllers/user_preference_controller.rb +++ b/app/controllers/user_preference_controller.rb @@ -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 = [] diff --git a/app/models/node.rb b/app/models/node.rb index f6726f91a..c45057e10 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -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 -- 2.39.5