No functional change here: this just prepares for adding other
decryption capabilities.

Signed-off-by: Daniel Kahn Gillmor <d...@fifthhorseman.net>
---
 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 7b8374d..d780883 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
-- 
2.24.0

Reply via email to