Re: What's needed for mutt 1.6? (Debian patches)
* Tue Feb 27 2007 TAKIZAWA Takashi <taki@xxxxxxxxxxxxxxxx>
> Perhaps the difference is:
> - a bugfix concerning memory allocation
> - "+tamo" part, which is result thing of discussion by Tamotsu and Alain
> - a new patch is safer.
Thanks for your explanation.
I (1) reverted the old patch (rev. 3fa665562a95) and
(2) applied your patches and
(3) saved "hg diff" as the attached patch.
Can you try this out?
Does it have the bug you mentioned above?
If it doesn't, it must be easier for Brendan to apply
than your three conflicting patches.
--
tamo
diff -r 3013f927b2f3 PATCHES
--- a/PATCHES Tue Feb 27 01:10:57 2007 +0000
+++ b/PATCHES Tue Feb 27 21:07:39 2007 +0900
@@ -0,0 +1,3 @@
+patch-1.5.14.tt.linear_white_space.1
+patch-1.5.14.tt.attach_charset.1
+patch-1.5.14.tt+tamo.assumed_charset.1
diff -r 3013f927b2f3 UPDATING
--- a/UPDATING Tue Feb 27 01:10:57 2007 +0000
+++ b/UPDATING Tue Feb 27 21:48:33 2007 +0900
@@ -5,7 +5,7 @@ The keys used are:
!: modified feature, -: deleted feature, +: new feature
+ $save_history, $history_file (save history across sessions)
- + $assumed_charset, $file_charset, $strict_mime
+ + $assumed_charset, $attach_charset, $ignore_linear_white_space
+ $smtp_url (ESMTP relay support)
+ $crypt_use_pka (use GPGME PKA signature verification)
diff -r 3013f927b2f3 charset.c
--- a/charset.c Tue Feb 27 01:10:57 2007 +0000
+++ b/charset.c Tue Feb 27 21:35:01 2007 +0900
@@ -282,6 +282,19 @@ int mutt_chscmp (const char *s, const ch
return !ascii_strcasecmp (buffer, chs);
}
+char *mutt_get_default_charset ()
+{
+ static char fcharset[SHORT_STRING];
+ const char *c = AssumedCharset;
+ const char *c1;
+
+ if (c && *c) {
+ c1 = strchr (c, ':');
+ strfcpy (fcharset, c, c1 ? (c1 - c + 1) : sizeof (fcharset));
+ return fcharset;
+ }
+ return strcpy (fcharset, "us-ascii"); /* __STRCPY_CHECKED__ */
+}
#ifndef HAVE_ICONV
@@ -606,71 +619,3 @@ const char *mutt_get_first_charset (cons
return fcharset;
}
-static size_t convert_string (ICONV_CONST char *f, size_t flen,
- const char *from, const char *to,
- char **t, size_t *tlen)
-{
- iconv_t cd;
- char *buf, *ob;
- size_t obl, n;
- int e;
-
- cd = mutt_iconv_open (to, from, 0);
- if (cd == (iconv_t)(-1))
- return (size_t)(-1);
- obl = 4 * flen + 1;
- ob = buf = safe_malloc (obl);
- n = iconv (cd, &f, &flen, &ob, &obl);
- if (n == (size_t)(-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t)(-1))
- {
- e = errno;
- FREE (&buf);
- iconv_close (cd);
- errno = e;
- return (size_t)(-1);
- }
- *ob = '\0';
-
- *tlen = ob - buf;
-
- safe_realloc ((void **) &buf, ob - buf + 1);
- *t = buf;
- iconv_close (cd);
-
- return n;
-}
-
-int mutt_convert_nonmime_string (char **ps)
-{
- const char *c, *c1;
-
- for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
- {
- char *u = *ps;
- char *s;
- char *fromcode;
- size_t m, n;
- size_t ulen = mutt_strlen (*ps);
- size_t slen;
-
- if (!u || !*u)
- return 0;
-
- c1 = strchr (c, ':');
- n = c1 ? c1 - c : mutt_strlen (c);
- if (!n)
- continue;
- fromcode = safe_malloc (n + 1);
- strfcpy (fromcode, c, n + 1);
- m = convert_string (u, ulen, fromcode, Charset, &s, &slen);
- FREE (&fromcode);
- if (m != (size_t)(-1))
- {
- FREE (ps); /* __FREE_CHECKED__ */
- *ps = s;
- return 0;
- }
- }
- return -1;
-}
-
diff -r 3013f927b2f3 charset.h
--- a/charset.h Tue Feb 27 01:10:57 2007 +0000
+++ b/charset.h Tue Feb 27 21:07:39 2007 +0900
@@ -35,8 +35,6 @@ int iconv_close (iconv_t);
#endif
int mutt_convert_string (char **, const char *, const char *, int);
-const char *mutt_get_first_charset (const char *);
-int mutt_convert_nonmime_string (char **);
iconv_t mutt_iconv_open (const char *, const char *, int);
size_t mutt_iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *,
ICONV_CONST char **, const char *);
@@ -49,6 +47,7 @@ void fgetconv_close (FGETCONV **);
void fgetconv_close (FGETCONV **);
void mutt_set_langinfo_charset (void);
+char *mutt_get_default_charset ();
#define M_ICONV_HOOK_FROM 1
#define M_ICONV_HOOK_TO 2
diff -r 3013f927b2f3 globals.h
--- a/globals.h Tue Feb 27 01:10:57 2007 +0000
+++ b/globals.h Tue Feb 27 21:07:39 2007 +0900
@@ -36,6 +36,7 @@ WHERE char *AssumedCharset;
WHERE char *AssumedCharset;
WHERE char *AttachSep;
WHERE char *Attribution;
+WHERE char *AttachCharset;
WHERE char *AttachFormat;
WHERE char *Charset;
WHERE char *ComposeFormat;
@@ -48,7 +49,6 @@ WHERE char *DsnReturn;
WHERE char *DsnReturn;
WHERE char *Editor;
WHERE char *EscChar;
-WHERE char *FileCharset;
WHERE char *FolderFormat;
WHERE char *ForwFmt;
WHERE char *Fqdn;
diff -r 3013f927b2f3 handler.c
--- a/handler.c Tue Feb 27 01:10:57 2007 +0000
+++ b/handler.c Tue Feb 27 21:07:39 2007 +0900
@@ -1748,8 +1748,8 @@ void mutt_decode_attachment (BODY *b, ST
if(s->flags & M_CHARCONV)
{
char *charset = mutt_get_parameter ("charset", b->parameter);
- if (!option (OPTSTRICTMIME) && !charset)
- charset = mutt_get_first_charset (AssumedCharset);
+ if (!charset && AssumedCharset && *AssumedCharset)
+ charset = mutt_get_default_charset ();
if (charset && Charset)
cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
}
diff -r 3013f927b2f3 init.h
--- a/init.h Tue Feb 27 01:10:57 2007 +0000
+++ b/init.h Tue Feb 27 21:29:19 2007 +0900
@@ -218,7 +218,7 @@ struct option_t MuttVars[] = {
** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
** editing the body of an outgoing message.
*/
- { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL "us-ascii"},
+ { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
/*
** .pp
** This variable is a colon-separated list of character encoding
@@ -233,7 +233,20 @@ struct option_t MuttVars[] = {
** set assumed_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
** .pp
** However, only the first content is valid for the message body.
- ** This variable is valid only if $$strict_mime is unset.
+ */
+ { "attach_charset", DT_STR, R_NONE, UL &AttachCharset, UL 0 },
+ /*
+ ** .pp
+ ** This variable is a colon-separated list of character encoding
+ ** schemes for text file attachments.
+ ** If unset, $$charset value will be used instead.
+ ** For example, the following configuration would work for Japanese
+ ** text handling:
+ ** .pp
+ ** set attach_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
+ ** .pp
+ ** Note: "iso-2022-*" must be put at the head of the value as shown above
+ ** if included.
*/
{ "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n
%T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
/*
@@ -614,19 +627,8 @@ struct option_t MuttVars[] = {
** signed.
** (PGP only)
*/
- { "file_charset", DT_STR, R_NONE, UL &FileCharset, UL 0 },
- /*
- ** .pp
- ** This variable is a colon-separated list of character encoding
- ** schemes for text file attatchments.
- ** If unset, $$charset value will be used instead.
- ** For example, the following configuration would work for Japanese
- ** text handling:
- ** .pp
- ** set file_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
- ** .pp
- ** Note: "iso-2022-*" must be put at the head of the value as shown above
- ** if included.
+ { "file_charset", DT_SYN, R_NONE, UL "attach_charset", 0 },
+ /*
*/
{ "folder", DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
/*
@@ -845,6 +847,13 @@ struct option_t MuttVars[] = {
** Specifies the hostname to use after the ``@'' in local e-mail
** addresses. This overrides the compile time definition obtained from
** /etc/resolv.conf.
+ */
+ { "ignore_linear_white_space", DT_BOOL, R_NONE, OPTIGNORELWS, 0 },
+ /*
+ ** .pp
+ ** This option replaces linear-white-space between encoded-word
+ ** and *text to a single space to prevent the display of MIME-encoded
+ ** ``Subject'' field from being devided into multiple lines.
*/
{ "ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0 },
/*
@@ -2595,7 +2604,7 @@ struct option_t MuttVars[] = {
** messages from the current folder. The default is to pause one second, so
** a value of zero for this option suppresses the pause.
*/
-#if USE_SMTP
+#ifdef USE_SMTP
{ "smtp_url", DT_STR, R_NONE, UL &SmtpUrl, UL 0 },
/*
** .pp
@@ -2807,19 +2816,6 @@ struct option_t MuttVars[] = {
** .pp
** Setting this variable causes the ``status bar'' to be displayed on
** the first line of the screen rather than near the bottom.
- */
- { "strict_mime", DT_BOOL, R_NONE, OPTSTRICTMIME, 1 },
- /*
- ** .pp
- ** When unset, non MIME-compliant messages that doesn't have any
- ** charset indication in ``Content-Type'' field can be displayed
- ** (non MIME-compliant messages are often generated by old mailers
- ** or buggy mailers like MS Outlook Express).
- ** See also $$assumed_charset.
- ** .pp
- ** This option also replaces linear-white-space between encoded-word
- ** and *text to a single space to prevent the display of MIME-encoded
- ** ``Subject'' field from being devided into multiple lines.
*/
{ "strict_threads", DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX,
OPTSTRICTTHREADS, 0 },
/*
diff -r 3013f927b2f3 mutt.h
--- a/mutt.h Tue Feb 27 01:10:57 2007 +0000
+++ b/mutt.h Tue Feb 27 21:07:40 2007 +0900
@@ -370,6 +370,7 @@ enum
OPTHIDETHREADSUBJECT,
OPTHIDETOPLIMITED,
OPTHIDETOPMISSING,
+ OPTIGNORELWS,
OPTIGNORELISTREPLYTO,
#ifdef USE_IMAP
OPTIMAPCHECKSUBSCRIBED,
@@ -428,7 +429,6 @@ enum
OPTSORTRE,
OPTSPAMSEP,
OPTSTATUSONTOP,
- OPTSTRICTMIME,
OPTSTRICTTHREADS,
OPTSUSPEND,
OPTTEXTFLOWED,
diff -r 3013f927b2f3 parse.c
--- a/parse.c Tue Feb 27 01:10:57 2007 +0000
+++ b/parse.c Tue Feb 27 21:07:40 2007 +0900
@@ -217,7 +217,7 @@ static PARAMETER *parse_parameters (cons
s++;
for (i=0; *s && i < sizeof (buffer) - 1; i++, s++)
{
- if (!option (OPTSTRICTMIME)) {
+ if (AssumedCharset && *AssumedCharset) {
/* As iso-2022-* has a characer of '"' with non-ascii state,
* ignore it. */
if (*s == 0x1b && i < sizeof (buffer) - 2)
@@ -402,9 +402,9 @@ void mutt_parse_content_type (char *s, B
if (ct->type == TYPETEXT)
{
if (!(pc = mutt_get_parameter ("charset", ct->parameter)))
- mutt_set_parameter ("charset", option (OPTSTRICTMIME) ? "us-ascii" :
- (const char *) mutt_get_first_charset
(AssumedCharset),
- &ct->parameter);
+ mutt_set_parameter ("charset", (AssumedCharset && *AssumedCharset) ?
+ (const char *) mutt_get_default_charset ()
+ : "us-ascii", &ct->parameter);
}
}
diff -r 3013f927b2f3 rfc2047.c
--- a/rfc2047.c Tue Feb 27 01:10:57 2007 +0000
+++ b/rfc2047.c Tue Feb 27 21:17:14 2007 +0900
@@ -85,6 +85,43 @@ static size_t convert_string (ICONV_CONS
iconv_close (cd);
return n;
+}
+
+int convert_nonmime_string (char **ps)
+{
+ const char *c, *c1;
+
+ for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
+ {
+ char *u = *ps;
+ char *s;
+ char *fromcode;
+ size_t m, n;
+ size_t ulen = mutt_strlen (*ps);
+ size_t slen;
+
+ if (!u || !*u)
+ return 0;
+
+ c1 = strchr (c, ':');
+ n = c1 ? c1 - c : mutt_strlen (c);
+ if (!n)
+ return 0;
+ fromcode = safe_malloc (n + 1);
+ strfcpy (fromcode, c, n + 1);
+ m = convert_string (u, ulen, fromcode, Charset, &s, &slen);
+ FREE (&fromcode);
+ if (m != (size_t)(-1))
+ {
+ FREE (ps);
+ *ps = s;
+ return 0;
+ }
+ }
+ mutt_convert_string (ps,
+ (const char *)mutt_get_default_charset (),
+ Charset, M_ICONV_HOOK_FROM);
+ return -1;
}
char *mutt_choose_charset (const char *fromcode, const char *charsets,
@@ -775,36 +812,30 @@ void rfc2047_decode (char **pd)
if (!(p = find_encoded_word (s, &q)))
{
/* no encoded words */
- if (!option (OPTSTRICTMIME))
+ if (option (OPTIGNORELWS))
{
n = mutt_strlen (s);
if (found_encoded && (m = lwslen (s, n)) != 0)
{
if (m != n)
*d = ' ', d++, dlen--;
- n -= m, s += m;
+ s += m;
}
- if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
- {
- char *t;
- size_t tlen;
-
- t = safe_malloc (n + 1);
- strfcpy (t, s, n + 1);
- if (mutt_convert_nonmime_string (&t) == 0)
- {
- tlen = mutt_strlen (t);
- strncpy (d, t, tlen);
- d += tlen;
- }
- else
- {
- strncpy (d, s, n);
- d += n;
- }
- FREE (&t);
- break;
- }
+ }
+ if (AssumedCharset && *AssumedCharset)
+ {
+ char *t;
+ size_t tlen;
+
+ n = mutt_strlen (s);
+ t = safe_malloc (n + 1);
+ strfcpy (t, s, n + 1);
+ convert_nonmime_string (&t);
+ tlen = mutt_strlen (t);
+ strncpy (d, t, tlen);
+ d += tlen;
+ FREE (&t);
+ break;
}
strncpy (d, s, dlen);
d += dlen;
@@ -816,7 +847,7 @@ void rfc2047_decode (char **pd)
n = (size_t) (p - s);
/* ignore spaces between encoded words
* and linear white spaces between encoded word and *text */
- if (!option (OPTSTRICTMIME))
+ if (option (OPTIGNORELWS))
{
if (found_encoded && (m = lwslen (s, n)) != 0)
{
@@ -865,7 +896,8 @@ void rfc2047_decode_adrlist (ADDRESS *a)
{
while (a)
{
- if (a->personal)
+ if (a->personal && ((strstr (a->personal, "=?") != NULL) ||
+ (AssumedCharset && *AssumedCharset)))
rfc2047_decode (&a->personal);
#ifdef EXACT_ADDRESS
if (a->val && strstr (a->val, "=?") != NULL)
diff -r 3013f927b2f3 rfc2047.h
--- a/rfc2047.h Tue Feb 27 01:10:57 2007 +0000
+++ b/rfc2047.h Tue Feb 27 21:07:40 2007 +0900
@@ -18,6 +18,7 @@
char *mutt_choose_charset (const char *fromcode, const char *charsets,
char *u, size_t ulen, char **d, size_t *dlen);
+int convert_nonmime_string (char **);
void _rfc2047_encode_string (char **, int, int);
void rfc2047_encode_adrlist (ADDRESS *, const char *);
diff -r 3013f927b2f3 rfc2231.c
--- a/rfc2231.c Tue Feb 27 01:10:57 2007 +0000
+++ b/rfc2231.c Tue Feb 27 21:07:40 2007 +0900
@@ -117,11 +117,8 @@ void rfc2231_decode_parameters (PARAMETE
if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?"))
rfc2047_decode (&p->value);
- else if (!option (OPTSTRICTMIME))
- {
- if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
- mutt_convert_nonmime_string (&p->value);
- }
+ else if (AssumedCharset && *AssumedCharset)
+ convert_nonmime_string (&p->value);
*last = p;
last = &p->next;
diff -r 3013f927b2f3 sendlib.c
--- a/sendlib.c Tue Feb 27 01:10:57 2007 +0000
+++ b/sendlib.c Tue Feb 27 21:07:40 2007 +0900
@@ -877,8 +877,8 @@ CONTENT *mutt_get_content_info (const ch
if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
{
char *chs = mutt_get_parameter ("charset", b->parameter);
- char *fchs = b->use_disp ? ((FileCharset && *FileCharset) ?
- FileCharset : Charset) : Charset;
+ char *fchs = b->use_disp ? ((AttachCharset && *AttachCharset) ?
+ AttachCharset : Charset) : Charset;
if (Charset && (chs || SendCharset) &&
convert_file_from_to (fp, fchs, chs ? chs : SendCharset,
&fromcode, &tocode, info) != (size_t)(-1))