Though controversial, I feel that this patch is in the best interest of
promoting the use of PGP with Mutt.

This patch adds a new boolean variable $pgp_search_text which will cause Mutt
to search for the first non-blank line in every text/plain message to see if
it is a mislabeled old-style PGP message.  NOTE: this should only be used as
a last resort if you absolutely can't use procmail to rewrite your messages
as suggested in doc/PGP-notes.txt.

I only tested this with Mutt 1.1.1i, but it should work with the 1.0 series
as well.

me
-- 
pgp key available from http://www.cs.hmc.edu/~me/elkins-pgp-key.asc
diff -durp mutt-1.1.1/doc/manual-6.html mutt-1.1.1.pgpsearchtext/doc/manual-6.html
--- mutt-1.1.1/doc/manual-6.html        Mon Nov  8 10:03:16 1999
+++ mutt-1.1.1.pgpsearchtext/doc/manual-6.html  Wed Jan  5 00:59:47 2000
@@ -1617,6 +1617,21 @@ variable is only used if ``mime_forward'
 ``mime_forward_decode'' is <EM>unset</EM>.
 <P>
 <P>
+<H3><A NAME="pgp_search_text"></A> pgp_search_text</H3>
+
+<P>Type: boolean<BR>
+Default: no
+<P>
+<P>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 &quot;-----BEGIN PGP&quot;
+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.
+<P>
+<P>
 <H3><A NAME="pipe_split"></A> pipe_split</H3>
 
 <P>Type: boolean<BR>
diff -durp mutt-1.1.1/doc/manual.sgml mutt-1.1.1.pgpsearchtext/doc/manual.sgml
--- mutt-1.1.1/doc/manual.sgml  Mon Nov  8 10:01:46 1999
+++ mutt-1.1.1.pgpsearchtext/doc/manual.sgml    Wed Jan  5 00:59:34 2000
@@ -4249,6 +4249,22 @@ variable is only used if ``mime&lowbar;f
 ``mime&lowbar;forward&lowbar;decode'' is <em>unset</em>.
 
 
+<sect2>pgp&lowbar;search&lowbar;text<label id="pgp_search_text">
+<p>
+Type: boolean<newline>
+Default: no
+
+<p>
+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 &dquot;-----BEGIN PGP&dquot;
+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.
+
+
 <sect2>pipe&lowbar;split<label id="pipe_split">
 <p>
 Type: boolean<newline>
diff -durp mutt-1.1.1/doc/muttrc.man mutt-1.1.1.pgpsearchtext/doc/muttrc.man
--- mutt-1.1.1/doc/muttrc.man   Mon Nov  8 10:01:47 1999
+++ mutt-1.1.1.pgpsearchtext/doc/muttrc.man     Wed Jan  5 00:59:48 2000
@@ -2226,6 +2226,23 @@ variable is only used if \(lqmime_forwar
 
 
 .TP
+.B pgp_search_text
+.nf
+Type: boolean
+Default: no
+.fi
+.IP
+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 \(rq-----BEGIN PGP\(rq
+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.
+
+
+.TP
 .B pipe_split
 .nf
 Type: boolean
diff -durp mutt-1.1.1/init.h mutt-1.1.1.pgpsearchtext/init.h
--- mutt-1.1.1/init.h   Sun Nov  7 13:15:24 1999
+++ mutt-1.1.1.pgpsearchtext/init.h     Wed Jan  5 00:58:50 2000
@@ -1276,6 +1276,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 */
   
   { "pipe_split",      DT_BOOL, R_NONE, OPTPIPESPLIT, 0 },
diff -durp mutt-1.1.1/mutt.h mutt-1.1.1.pgpsearchtext/mutt.h
--- mutt-1.1.1/mutt.h   Sun Nov  7 13:15:30 1999
+++ mutt-1.1.1.pgpsearchtext/mutt.h     Wed Jan  5 00:37:53 2000
@@ -355,6 +355,7 @@ enum
   OPTPGPSTRICTENC,
   OPTFORWDECRYPT,
   OPTPGPSHOWUNUSABLE,
+  OPTPGPSEARCHTEXT,
 #endif
 
   /* pseudo options */
diff -durp mutt-1.1.1/parse.c mutt-1.1.1.pgpsearchtext/parse.c
--- mutt-1.1.1/parse.c  Thu Sep 30 14:19:56 1999
+++ mutt-1.1.1.pgpsearchtext/parse.c    Wed Jan  5 00:46:30 2000
@@ -1260,6 +1260,50 @@ ENVELOPE *mutt_read_rfc822_header (FILE 
       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);

PGP signature

Reply via email to