fix: handle XML namespaces in DMARCParser for web.de/gmx.net compatibility

Agent-Logs-Url: https://github.com/christianlouis/dmarq/sessions/56611674-6132-435f-ab36-728464bb9157

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-29 17:59:13 +00:00
parent f7200d973c
commit 0844981bc0
3 changed files with 89 additions and 1 deletions
+9
View File
@@ -128,6 +128,14 @@ class DMARCParser:
return None
@staticmethod
def _strip_namespace(el) -> None:
"""Recursively remove XML namespace prefixes from element tags in-place."""
if "}" in el.tag:
el.tag = el.tag.split("}", 1)[1]
for child in el:
DMARCParser._strip_namespace(child)
@staticmethod
def _parse_metadata(root) -> dict:
"""Parse the report_metadata section of a DMARC XML report."""
@@ -216,6 +224,7 @@ class DMARCParser:
"""
try:
root = ET.fromstring(xml_content)
DMARCParser._strip_namespace(root)
report = DMARCParser._parse_metadata(root)