]> granicus.if.org Git - mutt/commitdiff
Make mutt_copy_message distinguish between fatal and non-fatal errors.
authorBrendan Cully <brendan@kublai.com>
Thu, 26 Jun 2008 05:43:32 +0000 (22:43 -0700)
committerBrendan Cully <brendan@kublai.com>
Thu, 26 Jun 2008 05:43:32 +0000 (22:43 -0700)
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
copy.c
crypt-gpgme.c
handler.c
mbox.c
pgp.c

index 264880c7bd4c71e0f95f19b68005ac88eaa7c121..69d561bbdb4481aaf02d6b11d8e1795efd86b68b 100644 (file)
@@ -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 4cb91d0cafe08653d6864eafdfca752daca14689..34272e02c3795601d39719785d7310bf86d74eab 100644 (file)
--- 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)
index ae5d87b982a361c48072a91557d16e3e239e46b0..ee0477c894c9efd7e5910693917f40be63e70673 100644 (file)
@@ -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"));
 
index 279f38a8c1bba07297a7418e055880f7d1a62040..89a06029d74504289669a31f9bfc5ee875bedf36 100644 (file)
--- 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 8111c237d3856e694669696fa2faf55600598170..bd55ee9d1cb82078e723e9082b7371b723f81d6e 100644 (file)
--- 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 29522c51c376ca5fe3e3b0e3fca8f0ae68e91504..15e38ea120646eca867507049a228c28fc4e795c 100644 (file)
--- 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;