summaryrefslogtreecommitdiff
path: root/email-print-mime-structure
diff options
context:
space:
mode:
Diffstat (limited to 'email-print-mime-structure')
-rwxr-xr-xemail-print-mime-structure6
1 files changed, 4 insertions, 2 deletions
diff --git a/email-print-mime-structure b/email-print-mime-structure
index 4f46f58..c22d556 100755
--- a/email-print-mime-structure
+++ b/email-print-mime-structure
@@ -70,8 +70,9 @@ class MimePrinter(object):
nbytes = len(payload)
print(f'{prefix}{z.get_content_type()}{cset}{disposition}{fname} {nbytes:d} bytes')
+ try_decrypt:bool = True if self.args.pgpkey else False
- if self.args.pgpkey and \
+ if try_decrypt and \
(parent is not None) and \
(parent.get_content_type().lower() == 'multipart/encrypted') and \
(str(parent.get_param('protocol')).lower() == 'application/pgp-encrypted') and \
@@ -81,7 +82,8 @@ class MimePrinter(object):
if not isinstance(ciphertext, str):
logging.warning('encrypted part was not a leaf mime part somehow')
return
- cryptopayload = self.pgpy_decrypt(self.args.pgpkey, ciphertext)
+ if self.args.pgpkey:
+ cryptopayload = self.pgpy_decrypt(self.args.pgpkey, ciphertext)
if cryptopayload is None:
logging.warning(f'Unable to decrypt')
return