summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--charset.c15
-rw-r--r--copy.c6
-rw-r--r--mbyte.c2
-rw-r--r--rfc2047.c11
-rw-r--r--sendlib.c10
5 files changed, 23 insertions, 21 deletions
diff --git a/charset.c b/charset.c
index 8961ebde..00efd6f5 100644
--- a/charset.c
+++ b/charset.c
@@ -38,17 +38,6 @@
# define EILSEQ EINVAL
#endif
-#ifdef HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-
-/*
- * Try to convert nl_langinfo's return value to something we can
- * use for MIME's purposes.
- *
- * Note that the algorithm used here is quite different from the
- * one in mutt_canonical_charset.
- */
-
/*
* The following list has been created manually from the data under:
* http://www.isi.edu/in-notes/iana/assignments/character-sets
@@ -191,6 +180,10 @@ PreferredMIMENames[] =
{ NULL, NULL }
};
+#ifdef HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+
+
void mutt_set_langinfo_charset (void)
{
char buff[LONG_STRING];
diff --git a/copy.c b/copy.c
index 58194003..1a9c61ca 100644
--- a/copy.c
+++ b/copy.c
@@ -284,16 +284,18 @@ int
mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
{
char buffer[SHORT_STRING];
-
+
if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
return (-1);
if (flags & CH_TXTPLAIN)
{
+ char chsbuf[SHORT_STRING];
fputs ("Mime-Version: 1.0\n", out);
fputs ("Content-Transfer-Encoding: 8bit\n", out);
fputs ("Content-Type: text/plain; charset=", out);
- rfc822_cat(buffer, sizeof(buffer), Charset ? Charset : "", MimeSpecials);
+ mutt_canonical_charset (chsbuf, sizeof (chsbuf), Charset ? Charset : "us-ascii");
+ rfc822_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials);
fputs(buffer, out);
fputc('\n', out);
diff --git a/mbyte.c b/mbyte.c
index ceb22728..c38e3fa9 100644
--- a/mbyte.c
+++ b/mbyte.c
@@ -41,7 +41,7 @@ static iconv_t charset_from_utf8 = (iconv_t)(-1);
void mutt_set_charset (char *charset)
{
- char buffer[8];
+ char buffer[STRING];
mutt_canonical_charset (buffer, sizeof (buffer), charset);
diff --git a/rfc2047.c b/rfc2047.c
index 255a6e08..f5217984 100644
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -357,7 +357,7 @@ static int rfc2047_encode (const char *d, size_t dlen, int col,
size_t ulen, r, n, wlen;
encoder_t encoder;
char *tocode1 = 0;
- const char *tocode;
+ char tocode[STRING];
char *icode = "UTF-8";
/* Try to convert to UTF-8. */
@@ -384,15 +384,18 @@ static int rfc2047_encode (const char *d, size_t dlen, int col,
}
/* Choose target charset. */
- tocode = fromcode;
+ mutt_canonical_charset (tocode, sizeof (tocode), fromcode);
if (icode)
{
if ((tocode1 = mutt_choose_charset (icode, charsets, u, ulen, 0, 0)))
- tocode = tocode1;
+ mutt_canonical_charset (tocode, sizeof (tocode), tocode1);
else
ret = 2, icode = 0;
}
-
+
+ if (mutt_is_us_ascii (tocode))
+ strfcpy (tocode, "unknown-8bit", sizeof (tocode));
+
/* Adjust t0 for maximum length of line. */
t = u + (ENCWORD_LEN_MAX + 1) - col - ENCWORD_LEN_MIN;
t = t > u ? t : u;
diff --git a/sendlib.c b/sendlib.c
index c3aca6ae..9f8f00d2 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -890,6 +890,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
FILE *fp = NULL;
char *tocode;
char buffer[100];
+ char chsbuf[STRING];
size_t r;
if(b && !fname) fname = b->filename;
@@ -912,7 +913,10 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
0, &tocode, info) != (size_t)(-1))
{
if (!chs)
+ {
+ mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode);
mutt_set_parameter ("charset", tocode, &b->parameter);
+ }
safe_free ((void **) &tocode);
safe_fclose (&fp);
return info;
@@ -928,7 +932,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
mutt_set_parameter ("charset", (!info->hibin ? "us-ascii" :
- Charset ? Charset : "unknown-8bit"),
+ Charset && !mutt_is_us_ascii (Charset) ? Charset : "unknown-8bit"),
&b->parameter);
return info;
@@ -1159,7 +1163,7 @@ static void mutt_set_encoding (BODY *b, CONTENT *info)
if (b->type == TYPETEXT)
{
char *chsname = mutt_get_body_charset (send_charset, sizeof (send_charset), b);
- if ((info->lobin && strncasecmp (chsname, "iso-2022-jp", 11)) || info->linemax > 990 || (info->from && option (OPTENCODEFROM)))
+ if ((info->lobin && strncasecmp (chsname, "iso-2022", 8)) || info->linemax > 990 || (info->from && option (OPTENCODEFROM)))
b->encoding = ENCQUOTEDPRINTABLE;
else if (info->hibin)
b->encoding = option (OPTALLOW8BIT) ? ENC8BIT : ENCQUOTEDPRINTABLE;
@@ -1210,7 +1214,7 @@ char *mutt_get_body_charset (char *d, size_t dlen, BODY *b)
p = mutt_get_parameter ("charset", b->parameter);
if (p)
- strfcpy (d, NONULL(p), dlen);
+ mutt_canonical_charset (d, dlen, NONULL(p));
else
strfcpy (d, "us-ascii", dlen);