domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
981 stars 212 forks source link

Uncaught exception if xml report is an empty string #348

Closed drawks closed 1 year ago

drawks commented 1 year ago

In this block https://github.com/domainaware/parsedmarc/blob/master/parsedmarc/__init__.py#L225 if xml is an empty string the parse operation will fail and remain uncaught, it will result in the cli.py raising/logging an error and exiting with a non-zero return code like so:

   ERROR:cli.py:618:IMAP Error: Document is empty, line 1, column 1 (<string>, line 1)

The parsing operation should guard against this by setting xml to a valid "zero value" on any parsing errors, something like '<a/>'.