]> granicus.if.org Git - neomutt/commitdiff
OK, I'm giving up: pgp_create_traditional now creates text/plain;
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 26 Mar 2002 20:34:23 +0000 (20:34 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 26 Mar 2002 20:34:23 +0000 (20:34 +0000)
x-mutt-action={pgp-encrypt,pgp-sign}.

commands.c
crypt.c
handler.c
pgp.c
pgpinvoke.c
sendlib.c

index d9bcb7190c899f992ade6ecadea53d637a98d6f7..85874b042f16f48770ca8fe61fffc4dee30ad3d6 100644 (file)
@@ -627,7 +627,7 @@ static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags,
       *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
       *cmflags = M_CM_DECODE_PGP;
     }
-    else if (mutt_is_application_pgp(hdr->content) & ENCRYPT)
+    else if (mutt_is_application_pgp (hdr->content) & ENCRYPT)
       decode = 1;
 #endif
 #if defined(HAVE_PGP) && defined(HAVE_SMIME)
diff --git a/crypt.c b/crypt.c
index 244ba4ca02a2b9f83cd811f57b14d19b13c543b3..ceb23e7472f134cf907ddd80aabe3953ceee60ca 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -180,7 +180,7 @@ int mutt_protect (HEADER *msg, char *keylist)
   if (msg->security & APPLICATION_PGP)
   {
     if ((msg->content->type == TYPETEXT) &&
-       !mutt_strcasecmp (msg->content->subtype, "plain") &&
+       !ascii_strcasecmp (msg->content->subtype, "plain") &&
        ((flags & ENCRYPT) || (msg->content->content && msg->content->content->hibin == 0)))
     {
       if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create an application/pgp message?"))) == -1)
@@ -360,6 +360,11 @@ int crypt_query (BODY *m)
     if (t && m->badsig) t |= BADSIGN;
 #endif
   }
+#ifdef HAVE_PGP
+  else if (m->type == TYPETEXT)
+    t |= mutt_is_application_pgp (m);
+#endif                   
+  
   
   if (m->type == TYPEMULTIPART)
   {
index a09ed403c4380c62cd130cbc1441dfe851b7f8e6..7b8e2df517668392505173fd1c5965c00d32a696 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1785,6 +1785,11 @@ void mutt_body_handler (BODY *b, STATE *s)
       /* avoid copying this part twice since removing the transfer-encoding is
        * the only operation needed.
        */
+#ifdef HAVE_PGP
+      if (mutt_is_application_pgp (b))
+       handler = pgp_application_pgp_handler;
+      else
+#endif 
       if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
        handler = text_plain_flowed_handler;
       else
@@ -1854,7 +1859,7 @@ void mutt_body_handler (BODY *b, STATE *s)
   else if (b->type == TYPEAPPLICATION)
   {
 #ifdef HAVE_PGP
-    if (mutt_is_application_pgp(b))
+    if (mutt_is_application_pgp (b))
       handler = pgp_application_pgp_handler;
 #endif /* HAVE_PGP */
 #ifdef HAVE_SMIME
diff --git a/pgp.c b/pgp.c
index 5f4b3650022d92e3d40cf2174deb624a13a787f1..920ebd05ec5975261435dbb221071d05bf76796b 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -441,7 +441,7 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
 
   if (tagged_only && !b->tagged)
     return 0;
-  
+
   mutt_mktemp (tempfile);
   if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0)
   {
@@ -454,7 +454,7 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     unlink (tempfile);
     return 0;
   }
-    
+  
   while (fgets (buf, sizeof (buf), tfp))
   {
     if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
@@ -465,7 +465,6 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
        sgn = 1;
     }
   }
-  
   safe_fclose (&tfp);
   unlink (tempfile);
 
@@ -486,12 +485,18 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
 int pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
 {
   int rv = 0;
+  int r;
   for (; b; b = b->next)
   {
     if (is_multipart (b))
       rv = pgp_check_traditional (fp, b->parts, tagged_only) || rv;
     else if (b->type == TYPETEXT)
-      rv = pgp_check_traditional_one_body (fp, b, tagged_only) || rv;
+    {
+      if ((r = mutt_is_application_pgp (b)))
+       rv = rv || r;
+      else
+       rv = pgp_check_traditional_one_body (fp, b, tagged_only) || rv;
+    }
   }
 
   return rv;
@@ -537,6 +542,14 @@ int mutt_is_application_pgp (BODY *m)
     if (!ascii_strcasecmp (m->subtype, "pgp-keys"))
       t |= PGPKEY;
   }
+  else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0)
+  {
+    if ((p = mutt_get_parameter ("x-mutt-action", m->parameter)) &&
+       !ascii_strcasecmp ("pgp-sign", p))
+      t |= PGPSIGN;
+    else if (p && !ascii_strcasecmp ("pgp-encrypt", p))
+      t |= PGPENCRYPT;
+  }
   return t;
 }
 
@@ -1264,6 +1277,8 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   char pgpoutfile[_POSIX_PATH_MAX];
   char pgperrfile[_POSIX_PATH_MAX];
   char pgpinfile[_POSIX_PATH_MAX];
+
+  char send_charset[STRING];
   
   FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
   FILE *fp;
@@ -1274,6 +1289,11 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   char buff[STRING];
 
   pid_t thepid;
+
+  if (a->type != TYPETEXT)
+    return NULL;
+  if (ascii_strcasecmp (a->subtype, "plain"))
+    return NULL;
   
   if ((fp = fopen (a->filename, "r")) == NULL)
   {
@@ -1362,13 +1382,15 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   
   b->encoding = ENC7BIT;
 
-  b->type = TYPEAPPLICATION;
-  b->subtype = safe_strdup ("pgp");
-
-  mutt_set_parameter ("format", "text", &b->parameter);
-  mutt_set_parameter ("x-action", flags & ENCRYPT ? "encrypt" : "sign",
+  b->type = TYPETEXT;
+  b->subtype = safe_strdup ("plain");
+  
+  mutt_set_parameter ("x-mutt-action", flags & ENCRYPT ? "pgp-encrypt" : "pgp-sign",
                      &b->parameter);
-
+  mutt_set_parameter ("charset", mutt_get_body_charset (send_charset, 
+                                                       sizeof (send_charset), a), 
+                     &b->parameter);
+  
   b->filename = safe_strdup (pgpoutfile);
   
   /* The following is intended to give a clue to some completely brain-dead 
index 2502785427387f521305b4794ee6bf9a7187edb1..c84afdf57c1e3a6b524b53054beeab86c561750b 100644 (file)
@@ -244,8 +244,8 @@ pid_t pgp_invoke_traditional (FILE **pgpin, FILE **pgpout, FILE **pgperr,
 {
   if (flags & ENCRYPT)
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                      flags & PGPSIGN ? 1 : 0, fname, NULL, PgpSignAs, uids, 
-                      flags & PGPSIGN ? PgpEncryptSignCommand : PgpEncryptOnlyCommand);
+                      flags & SIGN ? 1 : 0, fname, NULL, PgpSignAs, uids, 
+                      flags & SIGN ? PgpEncryptSignCommand : PgpEncryptOnlyCommand);
   else
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
                       1, fname, NULL, PgpSignAs, NULL,
index 3a12709a732db76c3265a20a1ff873575ad87c68..d5e082c9760bb99ed0c6fba3c8e9fda3c5a21980 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -500,7 +500,7 @@ int mutt_write_mime_body (BODY *a, FILE *f)
 
   if (a->type == TYPETEXT && (!a->noconv))
     fc = fgetconv_open (fpin, Charset, 
-                       mutt_get_body_charset (send_charset, sizeof (send_charset), a), 
+                       mutt_get_body_charset (send_charset, sizeof (send_charset), a),
                        M_ICONV_HOOK_TO);
   else
     fc = fgetconv_open (fpin, 0, 0, 0);