From 082789e1d4bddd9aafcdea319176515f2a033c6e Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Mon, 4 Oct 2021 20:17:20 +0200 Subject: [PATCH] fix CLI --- pyquarantine/cli.py | 7 ++++++- pyquarantine/storage.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyquarantine/cli.py b/pyquarantine/cli.py index 6dc0d1e..895f057 100644 --- a/pyquarantine/cli.py +++ b/pyquarantine/cli.py @@ -109,12 +109,17 @@ def list_quarantines(quarantines, args): else: whitelist_type = "NONE" + if "milter_action" in cfg: + milter_action = cfg["milter_action"] + else: + milter_action = "NONE" + qlist.append({ "name": q["name"], "storage": storage_type, "notification": notification_type, "whitelist": whitelist_type, - "action": q["args"]["milter_action"]}) + "action": milter_action}) print_table( [("Name", "name"), diff --git a/pyquarantine/storage.py b/pyquarantine/storage.py index 0cc4e14..a17c4b1 100644 --- a/pyquarantine/storage.py +++ b/pyquarantine/storage.py @@ -206,7 +206,12 @@ class FileMailStorage(BaseMailStorage): data = milter.fp.read mailfrom = milter.mailfrom recipients = list(milter.rcpts) - subject = "" + # getting the subject is the only operation that needs any + # parsing of the message, catch all exceptions here + try: + subject = milter.msg["subject"] or "" + except Exception as e: + subject = "" else: data = milter.msg.as_bytes mailfrom = milter.msginfo["mailfrom"]