Sometimes gpgmail fails, so let the legacy code handle the message

This commit is contained in:
nemunaire 2021-09-24 10:46:55 +02:00
parent d13d93c39c
commit 8f7d6e79c5

View File

@ -40,7 +40,7 @@ def gen_checks(gpgmail, submissions_dir, check_content=False, check_submission_h
else:
yield signcheck
if not gpgmail.valid:
if gpgmail is None or not gpgmail.valid:
yield (envelope.check, [GNUPG_DIRECTORY, not skip_public_key, BETA])
yield (signature.check, [GNUPG_DIRECTORY])
else:
@ -188,7 +188,10 @@ def readmail(fp):
import gnupg_mail
theEMail = fp.read()
try:
gpgmail = gnupg_mail.Message(theEMail.decode(), settings=gnupg_mail.Settings(log_level='debug',require_signed=True), gpg=gnupg.GPG(gnupghome=GNUPG_DIRECTORY))
except:
gpgmail = None
cnt = email.message_from_bytes(theEMail, policy=email.policy.default)
frm = cnt.get("From") or "someone"