diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2019-11-21 14:30:20 +0800 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-11-21 15:26:34 -0700 |
commit | 8ec259d84c40cd9832869edfab901ce4d48c7179 (patch) | |
tree | 8e5bb914b6308bd873165da4e122e0477f7a0125 | |
parent | 284392c2f70a65616af65f70575c6abe4b389288 (diff) | |
download | mailscripts-8ec259d84c40cd9832869edfab901ce4d48c7179.tar.gz |
email-print-mime-structure: prepare for multiple forms of decryption
As we prepare for S/MIME decryption, we want to identify pgp
decryption as just one type of decryption. There is no functional
change here.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Acked-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-x | email-print-mime-structure | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/email-print-mime-structure b/email-print-mime-structure index 4f165b1..27fb532 100755 --- a/email-print-mime-structure +++ b/email-print-mime-structure @@ -78,15 +78,16 @@ class MimePrinter(object): nbytes = len(payload) print(f'{prefix}{z.get_content_type()}{cset}{disposition}{fname} {nbytes:d} bytes') - try_decrypt:bool = self.args.pgpkey or self.args.use_gpg_agent + cryptopayload:Optional[Message] = None + ciphertext:Union[List[Message],str,bytes,None] = None + try_pgp_decrypt:bool = self.args.pgpkey or self.args.use_gpg_agent - if try_decrypt and \ + if try_pgp_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 \ (num == 2): - cryptopayload:Optional[Message] = None - ciphertext:Union[List[Message],str,bytes,None] = z.get_payload() + ciphertext = z.get_payload() if not isinstance(ciphertext, str): logging.warning('encrypted part was not a leaf mime part somehow') return @@ -97,6 +98,8 @@ class MimePrinter(object): if cryptopayload is None: logging.warning(f'Unable to decrypt') return + + if cryptopayload is not None: newprefix = prefix[:-3] + ' ' print(f'{newprefix}↧ (decrypts to)') self.print_tree(cryptopayload, newprefix + '└', z, 0) |