From c6e9138a57920988864e4652ca627d371a21732c Mon Sep 17 00:00:00 2001 From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de> Date: Tue, 27 Jul 2021 09:56:39 +0200 Subject: [PATCH] ... --- server.py | 11 +++++++---- utils.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index 56b1822..3ecb26c 100644 --- a/server.py +++ b/server.py @@ -51,16 +51,19 @@ def validate(): version = request.args.get('v') xml_str = request.data xml_tree = utils.parse(xml_str) - if xml_tree: + try: + utils.parse(xml_str) app.logger.debug('=== xml_tree OK ===') xsd_str = utils.get_xsd(releases_dict, xsd_version=version, xml_str=xml_str) if xsd_str: + app.logger.debug('=== xsd OK ===') ret = utils.validate(xml_str=xml_str, xsd_str=xsd_str) else: + app.logger.debug('=== xsd invalid ===') ret = utils.return_error(error='xsd content not readable') - else: - app.logger.debug('=== xml_tree invalid ===') - ret = utils.return_error(error='invalid xml data') + except: + app.logger.debug('=== xml_tree invalid ===') + ret = utils.return_error(error='invalid xml data') return utils.xml_response(ret) diff --git a/utils.py b/utils.py index f712b5e..1c815c8 100644 --- a/utils.py +++ b/utils.py @@ -53,9 +53,9 @@ def get_version(): return False def get_xsd(d, xsd_version=None, xml_str = None): - url = False + url = '' version = xsd_version - if not version: # We use the internal version information in the XML structure + if not version: # We use the internal version information in the XML data root = parse(xml_str) version = root.attrib.get('schemaVersion') for i in d['releases']: -- GitLab