From f12828485b4b303766b426591a6338ac65fa533b Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:23:11 -0400 Subject: [PATCH] Parse aggregate reports with multiple policy_published records --- parsedmarc/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index 6200ed12..4354c0ff 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -503,6 +503,8 @@ def parse_aggregate_report_xml( new_report["report_metadata"] = new_report_metadata records = [] policy_published = report["policy_published"] + if type(policy_published) is list: + policy_published = policy_published[0] new_policy_published = OrderedDict() new_policy_published["domain"] = policy_published["domain"] adkim = "r" @@ -519,17 +521,17 @@ def parse_aggregate_report_xml( sp = new_policy_published["p"] if "sp" in policy_published: if policy_published["sp"] is not None: - sp = report["policy_published"]["sp"] + sp = policy_published["sp"] new_policy_published["sp"] = sp pct = "100" if "pct" in policy_published: if policy_published["pct"] is not None: - pct = report["policy_published"]["pct"] + pct = policy_published["pct"] new_policy_published["pct"] = pct fo = "0" if "fo" in policy_published: if policy_published["fo"] is not None: - fo = report["policy_published"]["fo"] + fo = policy_published["fo"] new_policy_published["fo"] = fo new_report["policy_published"] = new_policy_published