From 0aafeb5da32fc18f510e537202d4bc4ac6bc8f79 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 26 Jan 2009 21:34:59 +0000 Subject: adding XML parsing to make sure POST content is welformed --- .../Modules/Avatar/Concierge/ConciergeServer.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py index f25ae9b..e5b1fd2 100755 --- a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py +++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py @@ -29,6 +29,9 @@ import logging import BaseHTTPServer +import xml.etree.ElementTree as ET +import xml.parsers.expat + # enable debug level logging logging.basicConfig(level = logging.DEBUG, @@ -58,6 +61,13 @@ class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler): self.logResponse(200) + def dumpXml(xml): + logging.debug('[ConciergeHandler] %s', xml.tag) + for attr in xml.attrib: + logging.debug('[ConciergeHandler] %s [%s] %s', xml.tag, attr, xml.attrib[attr]) + for kid in xml.getchildren: + dumpXml(kid) + def do_POST(self): self.logRequest() hdrs = {} @@ -69,6 +79,13 @@ class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler): self.rfile.close() logging.debug('[ConciergeHandler] POST: content: %s', content) + try: + postXml = ET.parse(content) + dumpXml(postXml) + except xml.parsers.expat.ExpatError, xmlError: + logging.error('[ConciergeHandler] POST illformed:%s', xmlError) + self.send_response(500) + return self.send_response(200) self.send_header('Content-type', 'text/html') -- cgit v1.1