<<< Date Index >>>     <<< Thread Index >>>

Re: 1.5.7 BUG: character set in traditional PGP



On Fri, Feb 11, 2005 at 12:33:55AM +0100, Dan Ohnesorg wrote:
> Dne Thu, Feb 10, 2005 at 10:21:17PM +0900, Tamotsu Takahashi napsal:
> 
> > -   fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
> > +   fc = fgetconv_open (pgpout, body_charset, Charset, 0);
> 
> This is from my point of view for sure bad solution.

Thanks for your information.
But I didn't mean it was a general solution.
The solution is PGP/MIME. :)


> I have also problem with gpg too, I get many messages which are starting in
> gpg like this:
> 
> -----BEGIN PGP MESSAGE-----
> Charset: ISO-8859-2
(snip)

Although I have never received non-MIME PGP-encrypted messages,
I rewrote the previous patch to (hopefully) accept such headers.
However, I don't recommend this patch. I haven't even tested it.

-- 
tamo
--- init.h.ORIG Fri Feb 11 17:30:37 2005
+++ init.h      Fri Feb 11 17:34:03 2005
@@ -1288,6 +1288,17 @@
   ** settings can be overridden by use of the \fIsmime-menu\fP.
   ** (Crypto only)
   */
+  { "pgp_charsethack", DT_BOOL, R_NONE, OPTPGPCHARSETHACK, 0},
+  /*
+  ** .pp
+  ** If \fIset\fP, Mutt will assume a non-MIME PGP armored message to be in
+  ** the charset specified in \fICharset:\fP armor header (by GnuPG) or in
+  ** \fIContent-Type\fP message header (by some MUAs). You should not set
+  ** this variable, because such an armor shouldn't have charset information.
+  ** By default, Mutt assumes such messages to be in UTF-8 (see RFC2440).
+  ** You will ignore the RFC if you set this variable!
+  ** (PGP only)
+  */
   { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
   /*
   ** .pp
--- mutt.h.ORIG Fri Feb 11 17:32:05 2005
+++ mutt.h      Fri Feb 11 17:31:55 2005
@@ -458,6 +458,7 @@
   OPTSMIMEISDEFAULT,
   OPTASKCERTLABEL,
   OPTSDEFAULTDECRYPTKEY,
+  OPTPGPCHARSETHACK,
   OPTPGPIGNORESUB,
   OPTPGPCHECKEXIT,
   OPTPGPLONGIDS,
--- pgp.c.ORIG  Fri Feb  4 17:49:59 2005
+++ pgp.c       Fri Feb 11 17:43:39 2005
@@ -249,6 +249,7 @@
   short maybe_goodsig = 1;
   short have_any_sigs = 0;
 
+  char *gpgcharset = NULL;
   char body_charset[STRING];
   mutt_get_body_charset (body_charset, sizeof (body_charset), m);
 
@@ -317,6 +318,12 @@
              && (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0
                  || mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) 
== 0)))
          break;
+       if (mutt_strncmp ("Charset: ", buf, 9) == 0)
+       {
+         char *end = strchr (buf + 9, '\n');
+         if (end)
+           gpgcharset = mutt_substrdup (buf + 9, end - 1);
+       }
       }
 
       /* leave tmpfp open in case we still need it - but flush it! */
@@ -383,9 +390,7 @@
       
 
       /*
-       * Now, copy cleartext to the screen.  NOTE - we expect that PGP
-       * outputs utf-8 cleartext.  This may not always be true, but it 
-       * seems to be a reasonable guess.
+       * Now, copy cleartext to the screen.
        */
 
       if(s->flags & M_DISPLAY)
@@ -408,12 +413,15 @@
       {
        FGETCONV *fc;
        int c;
+       char *expected_charset = ((!option (OPTPGPCHARSETHACK)) ? "utf-8" :
+                                 (gpgcharset ? gpgcharset : body_charset));
        rewind (pgpout);
        state_set_prefix (s);
-       fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
+       fc = fgetconv_open (pgpout, expected_charset, Charset, 
M_ICONV_HOOK_FROM);
        while ((c = fgetconv (fc)) != EOF)
          state_prefix_putc (c, s);
        fgetconv_close (&fc);
+       FREE (&gpgcharset);
       }
 
       if (s->flags & M_DISPLAY)