From 3425ccdbc097b01478c3be3c34160c4f06656922 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Wed, 25 Jun 2008 22:43:32 -0700 Subject: [PATCH] Make mutt_copy_message distinguish between fatal and non-fatal errors. Non-fatal errors should prevent moving messages, since they indicate data loss. But mutt should still attempt to display them, since being able to see some attachments is better than nothing. Also stop printing out non-PGP material in application/pgp attachments. Closes #2545, #2912. --- commands.c | 2 +- copy.c | 2 ++ crypt-gpgme.c | 19 +++++++++++-------- handler.c | 5 ++++- mbox.c | 3 ++- pgp.c | 3 +++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/commands.c b/commands.c index 264880c7b..69d561bbd 100644 --- a/commands.c +++ b/commands.c @@ -147,7 +147,7 @@ int mutt_display_message (HEADER *cur) res = mutt_copy_message (fpout, Context, cur, cmflags, (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM); - if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) + if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res < 0) { mutt_error (_("Could not copy message")); if (fpfilterout != NULL) diff --git a/copy.c b/copy.c index 4cb91d0ca..34272e02c 100644 --- a/copy.c +++ b/copy.c @@ -718,6 +718,8 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, return rc; } +/* should be made to return -1 on fatal errors, and 1 on non-fatal errors + * like partial decode, where it is worth displaying as much as possible */ int mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags, int chflags) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index ae5d87b98..ee0477c89 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -2096,7 +2096,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) char *tmpfname; { - /* Check wether signatures have been verified. */ + /* Check whether signatures have been verified. */ gpgme_verify_result_t verify_result; verify_result = gpgme_op_verify_result (ctx); @@ -2199,13 +2199,16 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) safe_fclose (&pgpout); } } +#if 0 else - { - /* XXX - we may wish to recode here */ - if (s->prefix) - state_puts (s->prefix, s); - state_puts (buf, s); - } + { + /* why would we want to display this at all? */ + /* XXX - we may wish to recode here */ + if (s->prefix) + state_puts (s->prefix, s); + state_puts (buf, s); + } +#endif } m->goodsig = (maybe_goodsig && have_any_sigs); @@ -2214,7 +2217,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s) { state_attach_puts (_("[-- Error: could not find beginning" " of PGP message! --]\n\n"), s); - return -1; + return 1; } dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n")); diff --git a/handler.c b/handler.c index 279f38a8c..89a06029d 100644 --- a/handler.c +++ b/handler.c @@ -1211,7 +1211,10 @@ int multipart_handler (BODY *a, STATE *s) if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED) mutt_free_body (&b); - + + /* make failure of a single part non-fatal */ + if (rc < 0) + rc = 1; return rc; } diff --git a/mbox.c b/mbox.c index 8111c237d..bd55ee9d1 100644 --- a/mbox.c +++ b/mbox.c @@ -833,7 +833,8 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) */ newOffset[i - first].hdr = ftello (fp) + offset; - if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1) + if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, + CH_FROM | CH_UPDATE | CH_UPDATE_LEN) != 0) { mutt_perror (tempfile); mutt_sleep (5); diff --git a/pgp.c b/pgp.c index 29522c51c..15e38ea12 100644 --- a/pgp.c +++ b/pgp.c @@ -467,13 +467,16 @@ int pgp_application_pgp_handler (BODY *m, STATE *s) state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s); } } +#if 0 else { + /* why would we want to display this at all? */ /* XXX - we may wish to recode here */ if (s->prefix) state_puts (s->prefix, s); state_puts (buf, s); } +#endif } rc = 0; -- 2.40.0