Commit 794abde7 authored by Brendan Cully's avatar Brendan Cully

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.
parent 5fbc0df4
......@@ -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)
......
......@@ -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)
......
......@@ -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"));
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment