From 17c7c3948c62f16f418420126ededdf43cc70221 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 11 Mar 2022 09:03:03 +0100 Subject: [PATCH] Handle XML parser errors Found in checkupdates of com.dar.nclientv2. --- fdroidserver/common.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 4a436e01..664e5cc8 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1564,7 +1564,11 @@ def retrieve_string(app_dir, string, xmlfiles=None): for path in xmlfiles: if not os.path.isfile(path): continue - xml = parse_xml(path) + try: + xml = parse_xml(path) + except XMLElementTree.ParseError: + logging.warning(_("Problem with xml at '{path}'").format(path=path)) + continue element = xml.find('string[@name="' + name + '"]') if element is not None: content = element_content(element) @@ -1606,7 +1610,11 @@ def fetch_real_name(app_dir, flavours): if not path.endswith('.xml') or not os.path.isfile(path): continue logging.debug("fetch_real_name: Checking manifest at " + path) - xml = parse_xml(path) + try: + xml = parse_xml(path) + except XMLElementTree.ParseError: + logging.warning(_("Problem with xml at '{path}'").format(path=path)) + continue app = xml.find('application') if app is None: continue