From bc35cd2bd19d4e29c46289c831170327f5c8e161 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sat, 9 Nov 2019 16:48:13 -0500 Subject: email-print-mime-structure: prepare for other decryption mechanisms No functional change here: this just prepares for adding other decryption capabilities. Signed-off-by: Daniel Kahn Gillmor Acked-by: Sean Whitton --- email-print-mime-structure | 6 ++++-- 1 file 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 -- cgit v1.2.3