diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2019-11-09 16:48:13 -0500 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-11-10 00:33:00 -0700 |
commit | bc35cd2bd19d4e29c46289c831170327f5c8e161 (patch) | |
tree | fc9815a0ff6f13f895719c1274355ab9e3316d30 /email-print-mime-structure | |
parent | b7a26158a2a87b51de86621107c01b24c2c8952d (diff) | |
download | mailscripts-bc35cd2bd19d4e29c46289c831170327f5c8e161.tar.gz |
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 <dkg@fifthhorseman.net>
Acked-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'email-print-mime-structure')
-rwxr-xr-x | email-print-mime-structure | 6 |
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 |