summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2019-11-09 16:48:13 -0500
committerSean Whitton <spwhitton@spwhitton.name>2019-11-10 00:33:00 -0700
commitbc35cd2bd19d4e29c46289c831170327f5c8e161 (patch)
treefc9815a0ff6f13f895719c1274355ab9e3316d30
parentb7a26158a2a87b51de86621107c01b24c2c8952d (diff)
downloadmailscripts-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>
-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