diff options
author | TechSneeze <dave@techsneeze.com> | 2020-04-30 00:36:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 00:36:23 +0300 |
commit | 88e2f55dcaabb99f12c8ba418a6f4e53ca640800 (patch) | |
tree | b3742dfb0484c1823cec816e3c2e1ca7599545c1 | |
parent | 3d108fd9f37578c398d980a73778768af3960594 (diff) | |
parent | 0c0ae92bd6f34efeab56b4e06b05850ac4d5c82f (diff) |
Merge pull request #74 from jschanz/master
validate policy_published element in xml
-rwxr-xr-x | dmarcts-report-parser.pl | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/dmarcts-report-parser.pl b/dmarcts-report-parser.pl index 410a196..a8f4072 100755 --- a/dmarcts-report-parser.pl +++ b/dmarcts-report-parser.pl @@ -717,12 +717,28 @@ sub storeXMLInDatabase { my $id = $xml->{'report_metadata'}->{'report_id'}; my $email = $xml->{'report_metadata'}->{'email'}; my $extra = $xml->{'report_metadata'}->{'extra_contact_info'}; - my $domain = $xml->{'policy_published'}->{'domain'}; - my $policy_adkim = $xml->{'policy_published'}->{'adkim'}; - my $policy_aspf = $xml->{'policy_published'}->{'aspf'}; - my $policy_p = $xml->{'policy_published'}->{'p'}; - my $policy_sp = $xml->{'policy_published'}->{'sp'}; - my $policy_pct = $xml->{'policy_published'}->{'pct'}; + my $domain = undef; + my $policy_adkim = undef; + my $policy_aspf = undef; + my $policy_p = undef; + my $policy_sp = undef; + my $policy_pct = undef; + + if (ref $xml->{'policy_published'} eq "HASH") { + $domain = $xml->{'policy_published'}->{'domain'}; + $policy_adkim = $xml->{'policy_published'}->{'adkim'}; + $policy_aspf = $xml->{'policy_published'}->{'aspf'}; + $policy_p = $xml->{'policy_published'}->{'p'}; + $policy_sp = $xml->{'policy_published'}->{'sp'}; + $policy_pct = $xml->{'policy_published'}->{'pct'}; + } else { + $domain = $xml->{'policy_published'}[0]->{'domain'}; + $policy_adkim = $xml->{'policy_published'}[0]->{'adkim'}; + $policy_aspf = $xml->{'policy_published'}[0]->{'aspf'}; + $policy_p = $xml->{'policy_published'}[0]->{'p'}; + $policy_sp = $xml->{'policy_published'}[0]->{'sp'}; + $policy_pct = $xml->{'policy_published'}[0]->{'pct'}; + } # see if already stored my $sth = $dbh->prepare(qq{SELECT org, serial FROM report WHERE reportid=?}); |