From: Andrew Engelbrecht Date: Sun, 19 Jul 2015 23:49:10 +0000 (-0400) Subject: search text/plain for keys and encoded messages X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=80119cabc495c19faa515e526241b0e792f88738;p=edward.git search text/plain for keys and encoded messages also don't scan the outer-most layer for keys because that gives corrupted files. they are still accessible under the content type of text/plain, even if the email's not a mime-formatted message. --- diff --git a/edward b/edward index ca6ef08..baf3059 100755 --- a/edward +++ b/edward @@ -59,9 +59,7 @@ def main (): gpgme_ctx = gpgme.Context() gpgme_ctx.armor = True - add_gpg_keys(email_text, gpgme_ctx) - - plaintext, keys = email_decode_flatten(email_text, gpgme_ctx) + plaintext, keys = email_decode_flatten(email_text, gpgme_ctx, False) encrypt_to_key = choose_reply_encryption_key(keys) reply_message = generate_reply(plaintext, email_from, \ @@ -72,7 +70,7 @@ def main (): print(reply_message) -def email_decode_flatten (email_text, gpgme_ctx): +def email_decode_flatten (email_text, gpgme_ctx, from_decryption): body = "" keys = [] @@ -109,10 +107,16 @@ def email_decode_flatten (email_text, gpgme_ctx): keys += add_gpg_keys(payload, gpgme_ctx) elif content_type == "text/plain": - body += payload + "\n" + if from_decryption == True: + body += payload + "\n" + + else: + plaintext, more_keys = decrypt_text(payload, gpgme_ctx) + + body += plaintext + keys += more_keys - else: - body += payload + "\n" + keys += add_gpg_keys(payload, gpgme_ctx) return body, keys @@ -193,7 +197,7 @@ def decrypt_text (gpg_text, gpgme_ctx): keys += [gpgme_ctx.get_key(sig.fpr)] # recursive for nested layers of mime and/or gpg - plaintext, more_keys = email_decode_flatten(plaintext, gpgme_ctx) + plaintext, more_keys = email_decode_flatten(plaintext, gpgme_ctx, True) body += plaintext keys += more_keys