]> granicus.if.org Git - neomutt/commitdiff
More inline PGP changes.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 26 Mar 2002 22:23:57 +0000 (22:23 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 26 Mar 2002 22:23:57 +0000 (22:23 +0000)
commands.c
compose.c
contrib/gpg.rc
crypt.c
handler.c
muttlib.c
pgp.c
protos.h
recvattach.c
sendlib.c

index 85874b042f16f48770ca8fe61fffc4dee30ad3d6..5090d1989fbd34f9de8662865f5bcd6c277d2790 100644 (file)
@@ -201,7 +201,7 @@ int mutt_display_message (HEADER *cur)
 #endif
 
 #ifdef HAVE_PGP
-    if (cur->security & APPLICATION_PGP && (cmflags & M_CM_VERIFY))
+    if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
       mutt_message ((cur->security & GOODSIGN) ?
                    _("PGP signature successfully verified.") :
                    _("PGP signature could NOT be verified."));
index f552faff17d6f271b5058d2b4652240ec8463d7e..7068fb6a0a173a9f2cf31b8c3f78f84b7859e498 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -948,7 +948,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
       case OP_COMPOSE_TOGGLE_RECODE:
       {      
         CHECK_COUNT;
-        if (!mutt_is_text_type (CURRENT->type, CURRENT->subtype))
+        if (!mutt_is_text_part (CURRENT))
         {
          mutt_error (_("Recoding only affects text attachments."));
          break;
index 7a652075090bc526495573984efbeb0d41b224a1..e12a521b77e12613631358bf590806d1b1799fc5 100644 (file)
@@ -31,7 +31,7 @@
 # breaking PGP/MIME.
 
 # decode application/pgp
-set pgp_decode_command="/usr/bin/gpg   %?p?--passphrase-fd 0? --no-verbose --quiet  --batch  --output - %f"
+set pgp_decode_command="/usr/bin/gpg  --charset utf-8   %?p?--passphrase-fd 0? --no-verbose --quiet  --batch  --output - %f"
 
 # verify a pgp/mime signature
 set pgp_verify_command="/usr/bin/gpg   --no-verbose --quiet  --batch  --output - --verify %s %f"
@@ -45,15 +45,15 @@ set pgp_sign_command="/usr/bin/gpg    --no-verbose --batch --quiet   --output -
 
 # create a application/pgp signed (old-style) message
 # set pgp_clearsign_command="/usr/bin/gpg-2comp --comment ''  --no-verbose --batch  --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
-set pgp_clearsign_command="/usr/bin/gpg   --no-verbose --batch --quiet   --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
+set pgp_clearsign_command="/usr/bin/gpg   --charset utf-8 --no-verbose --batch --quiet   --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
 
 # create a pgp/mime encrypted attachment
 # set pgp_encrypt_only_command="pgpewrap gpg-2comp  -v --batch  --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
-set pgp_encrypt_only_command="pgpewrap /usr/bin/gpg    --batch  --quiet  --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
+set pgp_encrypt_only_command="pgpewrap /usr/bin/gpg  --charset utf-8    --batch  --quiet  --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
 
 # create a pgp/mime encrypted and signed attachment
 # set pgp_encrypt_sign_command="pgpewrap gpg-2comp  --passphrase-fd 0 -v --batch  --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
-set pgp_encrypt_sign_command="pgpewrap /usr/bin/gpg  --passphrase-fd 0  --batch --quiet  --no-verbose  --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
+set pgp_encrypt_sign_command="pgpewrap /usr/bin/gpg  --charset utf-8 --passphrase-fd 0  --batch --quiet  --no-verbose  --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
 
 # import a key into the public key ring
 set pgp_import_command="/usr/bin/gpg  --no-verbose --import -v %f"
diff --git a/crypt.c b/crypt.c
index ceb23e7472f134cf907ddd80aabe3953ceee60ca..95b1fee91bd426d3a3164af962a81dfed197db63 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -180,10 +180,9 @@ int mutt_protect (HEADER *msg, char *keylist)
   if (msg->security & APPLICATION_PGP)
   {
     if ((msg->content->type == TYPETEXT) &&
-       !ascii_strcasecmp (msg->content->subtype, "plain") &&
-       ((flags & ENCRYPT) || (msg->content->content && msg->content->content->hibin == 0)))
+       !ascii_strcasecmp (msg->content->subtype, "plain"))
     {
-      if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create an application/pgp message?"))) == -1)
+      if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create an inline PGP message?"))) == -1)
        return -1;
       else if (i == M_YES)
        traditional = 1;
@@ -362,7 +361,11 @@ int crypt_query (BODY *m)
   }
 #ifdef HAVE_PGP
   else if (m->type == TYPETEXT)
+  {
     t |= mutt_is_application_pgp (m);
+    if (t && m->goodsig)
+      t |= GOODSIGN;
+  }
 #endif                   
   
   
@@ -761,7 +764,7 @@ void mutt_signed_handler (BODY *a, STATE *s)
       mutt_unlink (tempfile);
 
       b->goodsig = goodsig;
-      b->badsig = goodsig;
+      b->badsig = goodsig;             /* XXX - WHAT!?!?!? */
       
       /* Now display the signed body */
       state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
index 7b8e2df517668392505173fd1c5965c00d32a696..eba8eec8fdb45c2afe2783c4b48cc822e98f2818 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1720,7 +1720,7 @@ static void external_body_handler (BODY *b, STATE *s)
 
 void mutt_decode_attachment (BODY *b, STATE *s)
 {
-  int istext = mutt_is_text_type (b->type, b->subtype);
+  int istext = mutt_is_text_part (b);
   iconv_t cd = (iconv_t)(-1);
 
   if (istext && s->flags & M_CHARCONV)
@@ -1879,7 +1879,7 @@ void mutt_body_handler (BODY *b, STATE *s)
     /* see if we need to decode this part before processing it */
     if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
        b->encoding == ENCUUENCODED || plaintext || 
-       mutt_is_text_type (b->type, b->subtype))        /* text subtypes may
+       mutt_is_text_part (b))                          /* text subtypes may
                                                         * require character
                                                         * set conversion even
                                                         * with 8bit encoding.
index 4c2da94936ce496878845b5ec0c3c56893a6b12a..23aa16632a961aa1dc05f3dd2ee29d266e0f4331 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -138,7 +138,7 @@ int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src)
   b->use_disp = use_disp;
   b->unlink = 1;
 
-  if (mutt_is_text_type (b->type, b->subtype))
+  if (mutt_is_text_part (b))
     b->noconv = 1;
 
   b->xtype = safe_strdup (b->xtype);
@@ -616,8 +616,16 @@ int mutt_needs_mailcap (BODY *m)
   return 1;
 }
 
-int mutt_is_text_type (int t, char *s)
+int mutt_is_text_part (BODY *b)
 {
+  int t = b->type;
+  char *s = b->subtype;
+  
+  
+#ifdef HAVE_PGP
+  if (mutt_is_application_pgp (b))
+    return 0;
+#endif
   if (t == TYPETEXT)
     return 1;
 
diff --git a/pgp.c b/pgp.c
index 32ed90c8713aaf858ed87d4ef5cc36704d55b513..ae9b16043e58d5633228697a08eb7a7fd59b4845 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -364,18 +364,27 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
          state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
       }
 
-      /* Use PGP's output if there was no clearsig signature. */
-      
+      /*
+       * Use PGP's output if there was no clearsig signature.
+       * Assume it's utf-8.
+       */
+
       if(!clearsign && pgpout)
       {
+       int c;
+       FGETCONV *fc;
+       
        fflush (pgpout);
        rewind (pgpout);
-       while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL)
+       
+       fc = fgetconv_open (pgpout, "utf-8", Charset, M_ICONV_HOOK_TO);
+       while ((c = fgetconv (fc)) != EOF)
        {
-         if (s->prefix)
+         state_putc (c, s);
+         if (c == '\n' && s->prefix)
            state_puts (s->prefix, s);
-         state_puts (buf, s);
        }
+       fgetconv_close (&fc);
       }
 
       /* Close the temporary files iff they were created. 
@@ -1280,7 +1289,7 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   char pgperrfile[_POSIX_PATH_MAX];
   char pgpinfile[_POSIX_PATH_MAX];
 
-  char send_charset[STRING];
+  const char *send_charset;
   
   FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
   FILE *fp;
@@ -1311,8 +1320,28 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
     return NULL;
   }
 
-  mutt_copy_stream (fp, pgpin);
-  fclose (fp);
+  if (!mutt_is_us_ascii (Charset))
+  {
+    int c;
+    FGETCONV *fc;
+    
+    if (flags & ENCRYPT)
+      send_charset = "us-ascii";
+    else
+      send_charset = "utf-8";
+    
+    fc = fgetconv_open (fp, Charset, "utf-8", M_ICONV_HOOK_FROM);
+    while ((c = fgetconv (fc)) != EOF)
+      fputc (c, pgpin);
+    
+    fgetconv_close (&fc);
+  }
+  else
+  {
+    send_charset = "us-ascii";
+    mutt_copy_stream (fp, pgpin);
+  }
+  safe_fclose (&fp);
   fclose (pgpin);
 
   mutt_mktemp (pgpoutfile);
@@ -1387,11 +1416,9 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   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), 
+  mutt_set_parameter ("x-action", flags & ENCRYPT ? "pgp-encrypt" : "pgp-sign",
                      &b->parameter);
+  mutt_set_parameter ("charset", send_charset, &b->parameter);
   
   b->filename = safe_strdup (pgpoutfile);
   
@@ -1404,6 +1431,11 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   b->unlink   = 1;
   b->use_disp = 1;
 
+  b->noconv = 1;
+  
+  if (!(flags & ENCRYPT))
+    b->encoding = a->encoding;
+  
   return b;
 }
 
index 895e66165bf102f18ba092a1918551e4364a4096..33c8bfd59f955b542ecab5afd7302e3ec07ddf86 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -287,7 +287,7 @@ int mutt_is_message_type(int, const char *);
 int mutt_is_list_cc (int, ADDRESS *, ADDRESS *);
 int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *);
 int mutt_is_subscribed_list (ADDRESS *);
-int mutt_is_text_type (int, char *);
+int mutt_is_text_part (BODY *);
 int mutt_is_valid_mailbox (const char *);
 int mutt_lookup_mime_type (BODY *, const char *);
 int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
index ab6479edee6bb344267a43c04d7dea9acbe640de..7e210349993090b82f0f1f838fad4a5f04e97fbb 100644 (file)
@@ -201,13 +201,13 @@ const char *mutt_attach_fmt (char *dest,
     case 'C':
       if (!optional)
       {
-       if (mutt_is_text_type (aptr->content->type, aptr->content->subtype) &&
+       if (mutt_is_text_part (aptr->content) &&
            mutt_get_body_charset (charset, sizeof (charset), aptr->content))
          mutt_format_s (dest, destlen, prefix, charset);
        else
          mutt_format_s (dest, destlen, prefix, "");
       }
-      else if (!mutt_is_text_type (aptr->content->type, aptr->content->subtype) ||
+      else if (!mutt_is_text_part (aptr->content) ||
               !mutt_get_body_charset (charset, sizeof (charset), aptr->content))
         optional = 0;
       break;
index d5e082c9760bb99ed0c6fba3c8e9fda3c5a21980..1a10518725a833d07176e636a542d2a978b11e3e 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -506,11 +506,11 @@ int mutt_write_mime_body (BODY *a, FILE *f)
     fc = fgetconv_open (fpin, 0, 0, 0);
 
   if (a->encoding == ENCQUOTEDPRINTABLE)
-    encode_quoted (fc, f, mutt_is_text_type (a->type, a->subtype));
+    encode_quoted (fc, f, mutt_is_text_part (a));
   else if (a->encoding == ENCBASE64)
-    encode_base64 (fc, f, mutt_is_text_type (a->type, a->subtype));
+    encode_base64 (fc, f, mutt_is_text_part (a));
   else if (a->type == TYPETEXT && (!a->noconv))
-    encode_8bit (fc, f, mutt_is_text_type (a->type, a->subtype));
+    encode_8bit (fc, f, mutt_is_text_part (a));
   else
     mutt_copy_stream (fpin, f);