Original version: http://www.emaillab.org/mutt/1.5.14/patch-1.5.14.tamo.pgp_charsethack.1 How to use it? 1. copy /usr/ports/mail/mutt-devel in your $HOME/ports $ cp -r /usr/ports/mail/mutt-devel ~/ports 2. expand the distfile and apply FreeBSD patches $ cd ~/ports/mutt-devel $ make patch 3. apply the patch $ cd work/mutt-1.5.16 $ patch -p1 < /path/to/mutt-1.5.15.tamo.pgp_charsethack.1_FreeBSD.patch 4. compile the package $ cd ../.. $ make build 5. install it ($ sudo pkg_deinstall mutt-devel # if you have a previous version) $ sudo make install diff -uNr mutt-1.5.15.orig/PATCHES mutt-1.5.15/PATCHES --- mutt-1.5.15.orig/PATCHES Sat Apr 21 16:51:27 2007 +++ mutt-1.5.15/PATCHES Thu Apr 19 09:21:57 2007 @@ -1,3 +1,4 @@ +patch-1.5.14.tamo.pgp_charsethack.1 vvv.quote patch-1.5.0.ats.date_conditional.1 dgc.deepif.1 diff -uNr mutt-1.5.15.orig/init.h mutt-1.5.15/init.h --- mutt-1.5.15.orig/init.h Sat Apr 21 16:51:28 2007 +++ mutt-1.5.15/init.h Thu Apr 19 09:21:57 2007 @@ -1405,6 +1405,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 diff -uNr mutt-1.5.15.orig/mutt.h mutt-1.5.15/mutt.h --- mutt-1.5.15.orig/mutt.h Sat Apr 21 16:51:28 2007 +++ mutt-1.5.15/mutt.h Thu Apr 19 09:21:57 2007 @@ -482,6 +482,7 @@ OPTASKCERTLABEL, OPTSMIMENOSENDER, OPTSDEFAULTDECRYPTKEY, + OPTPGPCHARSETHACK, OPTPGPIGNORESUB, OPTPGPCHECKEXIT, OPTPGPLONGIDS, diff -uNr mutt-1.5.15.orig/pgp.c mutt-1.5.15/pgp.c --- mutt-1.5.15.orig/pgp.c Sun Apr 1 23:58:57 2007 +++ mutt-1.5.15/pgp.c Sat Apr 21 16:49:27 2007 @@ -264,6 +264,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); @@ -332,6 +333,8 @@ && (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) + gpgcharset = mutt_substrdup (buf + 9, NULL); } /* leave tmpfp open in case we still need it - but flush it! */ @@ -417,9 +420,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) @@ -442,12 +443,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) @@ -1422,13 +1426,11 @@ int c; FGETCONV *fc; - if (flags & ENCRYPT) - send_charset = "us-ascii"; - else - send_charset = "utf-8"; - - /* fromcode is assumed to be correct: we set flags to 0 */ - fc = fgetconv_open (fp, from_charset, "utf-8", 0); + send_charset = option(OPTPGPCHARSETHACK) ? body_charset : + ((flags & ENCRYPT) ? "us-ascii" : "utf-8"); + fc = fgetconv_open (fp, from_charset, + option(OPTPGPCHARSETHACK) ? send_charset : "utf-8", + M_ICONV_HOOK_FROM); while ((c = fgetconv (fc)) != EOF) fputc (c, pgpin);