mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-04-28 16:29:29 +00:00
Keep error message when recovering from bad XML
This commit is contained in:
@@ -218,11 +218,11 @@ def parse_aggregate_report_xml(xml, offline=False, nameservers=None,
|
||||
OrderedDict: The parsed aggregate DMARC report
|
||||
"""
|
||||
errors = []
|
||||
|
||||
# Parse XML and recover from errors
|
||||
try:
|
||||
xmltodict.parse(xml)["feedback"]
|
||||
except Exception as e:
|
||||
errors.append("Invalid XML: {0}".format(e.__str__()))
|
||||
tree = etree.parse(BytesIO(xml.encode('utf-8')),
|
||||
etree.XMLParser(recover=True))
|
||||
xml = etree.tostring(tree).decode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user