summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--init.h12
-rw-r--r--mutt.h1
-rw-r--r--parse.c44
3 files changed, 57 insertions, 0 deletions
diff --git a/init.h b/init.h
index a6bb84ec..6f90c34d 100644
--- 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 44935855..7c09fb34 100644
--- 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 64227830..0a942434 100644
--- 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);