summaryrefslogtreecommitdiffstats
path: root/keystone/middleware
diff options
context:
space:
mode:
authorDavid Höppner <0xffea@gmail.com>2013-03-10 20:04:07 +0100
committerDavid Höppner <0xffea@gmail.com>2013-03-14 16:07:39 +0100
commita80a1f8b300cadf69a3ad385cfe0d39a6ad2b9b1 (patch)
treef56c909009b79dde614bb1bcd4530b71a37ffecf /keystone/middleware
parentf6a2691caf06ee02cc9d245855c3b3012427980d (diff)
downloadkeystone-a80a1f8b300cadf69a3ad385cfe0d39a6ad2b9b1.tar.gz
keystone-a80a1f8b300cadf69a3ad385cfe0d39a6ad2b9b1.tar.xz
keystone-a80a1f8b300cadf69a3ad385cfe0d39a6ad2b9b1.zip
xml_body returns backtrace on XMLSyntaxError
Protected against XMLSyntaxError that can occur in from_xml. Return a validation error (400) instead of an internal server error (500). Change-Id: Ic5160f4f6c810e96b74dbf9563547ac739a54c5e Fixes: bug #1101043
Diffstat (limited to 'keystone/middleware')
-rw-r--r--keystone/middleware/core.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/keystone/middleware/core.py b/keystone/middleware/core.py
index 29a6832b..99cba4a0 100644
--- a/keystone/middleware/core.py
+++ b/keystone/middleware/core.py
@@ -149,7 +149,14 @@ class XmlBodyMiddleware(wsgi.Middleware):
incoming_xml = 'application/xml' in str(request.content_type)
if incoming_xml and request.body:
request.content_type = 'application/json'
- request.body = jsonutils.dumps(serializer.from_xml(request.body))
+ try:
+ request.body = jsonutils.dumps(
+ serializer.from_xml(request.body))
+ except Exception:
+ LOG.exception('Serializer failed')
+ e = exception.ValidationError(attribute='valid XML',
+ target='request body')
+ return wsgi.render_exception(e)
def process_response(self, request, response):
"""Transform the response from JSON to XML."""