diff options
-rw-r--r-- | init.h | 12 | ||||
-rw-r--r-- | mutt.h | 1 | ||||
-rw-r--r-- | parse.c | 44 |
3 files changed, 57 insertions, 0 deletions
@@ -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 @@ -360,6 +360,7 @@ enum OPTPGPSTRICTENC, OPTFORWDECRYPT, OPTPGPSHOWUNUSABLE, + OPTPGPSEARCHTEXT, #endif /* pseudo options */ @@ -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); |