]> granicus.if.org Git - neomutt/commitdiff
patch-1.1.1.me.pgpsearchtext.1. From Michael Elkins.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 5 Jan 2000 09:40:52 +0000 (09:40 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 5 Jan 2000 09:40:52 +0000 (09:40 +0000)
init.h
mutt.h
parse.c

diff --git a/init.h b/init.h
index a6bb84ec5752b900aa9c7c6e2936639853e5fc5d..6f90c34d11c35f9275c80a499afe926e5055129e 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1306,6 +1306,18 @@ struct option_t MuttVars[] = {
   { "forw_decrypt",    DT_SYN,  R_NONE, UL "forward_decrypt", 0 },
   /*
   */
+  { "pgp_search_text", DT_BOOL, R_NONE, OPTPGPSEARCHTEXT, 0 },
+  /*
+  ** .pp
+  ** Controls whether Mutt will search text/plain messages for old style
+  ** PGP message which are not properly labled using MIME header fields.
+  ** If the first non-blank line in a message contains "-----BEGIN PGP"
+  ** it will be assumed that it is an aplication/pgp content-type.
+  ** NOTE: this option should only be used as a last resort when procmail
+  ** is not available on your system. See doc/PGP-notes.txt for the
+  ** recommended way to handle old-style messages.  Using this option may
+  ** lead to longer time required to parse your mailbox.
+  */
 #endif /* _PGPPATH */
   
 #ifdef USE_SSL
diff --git a/mutt.h b/mutt.h
index 44935855f4ff8d67e5f66e4c0b8ab15aa0d44367..7c09fb345af61b688ee331ad53879629f35818b7 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -360,6 +360,7 @@ enum
   OPTPGPSTRICTENC,
   OPTFORWDECRYPT,
   OPTPGPSHOWUNUSABLE,
+  OPTPGPSEARCHTEXT,
 #endif
 
   /* pseudo options */
diff --git a/parse.c b/parse.c
index 6422783022398473efe30fa6b1bcb1ba4e649c46..0a9424341ed929d3e496a7a067ac2fbd52b16ded 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1266,6 +1266,50 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
       dprint(1,(debugfile,"read_rfc822_header(): no date found, using received time from msg separator\n"));
       hdr->date_sent = hdr->received;
     }
+
+#ifdef _PGPPATH
+    if (option (OPTPGPSEARCHTEXT) && hdr->content->type == TYPETEXT &&
+           !strcasecmp("plain",hdr->content->subtype))
+    {
+       char scratch[LONG_STRING];
+
+       /* continue reading until we hit the first line of text in the message.
+          we check here to see if this might be an old-style PGP message
+          which is not properly labeled */
+
+       /* save this location so we can return here */
+       loc = ftell (f);
+
+       while (fgets (scratch, sizeof (scratch), f) != NULL)
+       {
+           p = scratch;
+           SKIPWS (p);
+           if (*p != '\n')
+           {
+               /* we got a non-empty line, check it */
+               if (!strncmp ("-----BEGIN PGP", scratch, 14))
+               {
+                   /* yes, this looks like an old style pgp message, alter
+                      the apparent content-type so that we handle this
+                      corrrectly */
+                   hdr->content->type = TYPEAPPLICATION;
+                   FREE (&hdr->content->subtype);
+                   hdr->content->subtype = safe_strdup ("pgp");
+                   mutt_free_parameter (&hdr->content->parameter);
+                   mutt_set_parameter ("format", "text", &hdr->content->parameter);
+                   /* check to see what type of PGP message we have */
+                   mutt_set_parameter ("x-action",
+                           !strncmp (" SI", scratch + 14, 3) ? "sign" : "encrypt",
+                           &hdr->content->parameter);
+               }
+               break;
+           }
+       }
+
+       /* return to where we ended before */
+       fseek (f, loc, SEEK_SET);
+    }
+#endif /* _PGPPATH */
   }
 
   return (e);