···17431743 int istext = mutt_is_text_part (b);
17441744 iconv_t cd = (iconv_t)(-1);
1745174517461746- if (istext)
17461746+ if (istext && s->flags & M_CHARCONV)
17471747 {
17481748- if(s->flags & M_CHARCONV)
17491749- {
17501750- char *charset = mutt_get_parameter ("charset", b->parameter);
17511751- if (!option (OPTSTRICTMIME) && !charset)
17521752- charset = mutt_get_first_charset (AssumedCharset);
17531753- if (charset && Charset)
17541754- cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
17551755- }
17561756- else
17571757- {
17581758- if (b->file_charset)
17591759- cd = mutt_iconv_open (Charset, b->file_charset, M_ICONV_HOOK_FROM);
17601760- }
17481748+ char *charset = mutt_get_parameter ("charset", b->parameter);
17491749+ if (!charset && AssumedCharset && *AssumedCharset)
17501750+ charset = mutt_get_default_charset ();
17511751+ if (charset && Charset)
17521752+ cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
17611753 }
17541754+ else if (istext && b->charset)
17551755+ cd = mutt_iconv_open (Charset, b->charset, M_ICONV_HOOK_FROM);
1762175617631757 fseeko (s->fpin, b->offset, 0);
17641758 switch (b->encoding)
+23-27
init.h
···218218 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
219219 ** editing the body of an outgoing message.
220220 */
221221- { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL "us-ascii"},
221221+ { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
222222 /*
223223 ** .pp
224224 ** This variable is a colon-separated list of character encoding
···233233 ** set assumed_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
234234 ** .pp
235235 ** However, only the first content is valid for the message body.
236236- ** This variable is valid only if $$strict_mime is unset.
236236+ */
237237+ { "attach_charset", DT_STR, R_NONE, UL &AttachCharset, UL 0 },
238238+ /*
239239+ ** .pp
240240+ ** This variable is a colon-separated list of character encoding
241241+ ** schemes for text file attachments.
242242+ ** If unset, $$charset value will be used instead.
243243+ ** For example, the following configuration would work for Japanese
244244+ ** text handling:
245245+ ** .pp
246246+ ** set attach_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
247247+ ** .pp
248248+ ** Note: "iso-2022-*" must be put at the head of the value as shown above
249249+ ** if included.
237250 */
238251 { "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
239252 /*
···614627 ** signed.
615628 ** (PGP only)
616629 */
617617- { "file_charset", DT_STR, R_NONE, UL &FileCharset, UL 0 },
630630+ { "file_charset", DT_SYN, R_NONE, UL "attach_charset", 0 },
618631 /*
619619- ** .pp
620620- ** This variable is a colon-separated list of character encoding
621621- ** schemes for text file attatchments.
622622- ** If unset, $$charset value will be used instead.
623623- ** For example, the following configuration would work for Japanese
624624- ** text handling:
625625- ** .pp
626626- ** set file_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
627627- ** .pp
628628- ** Note: "iso-2022-*" must be put at the head of the value as shown above
629629- ** if included.
630632 */
631633 { "folder", DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
632634 /*
···845847 ** Specifies the hostname to use after the ``@'' in local e-mail
846848 ** addresses. This overrides the compile time definition obtained from
847849 ** /etc/resolv.conf.
850850+ */
851851+ { "ignore_linear_white_space", DT_BOOL, R_NONE, OPTIGNORELWS, 0 },
852852+ /*
853853+ ** .pp
854854+ ** This option replaces linear-white-space between encoded-word
855855+ ** and *text to a single space to prevent the display of MIME-encoded
856856+ ** ``Subject'' field from being divided into multiple lines.
848857 */
849858 { "ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0 },
850859 /*
···28072816 ** .pp
28082817 ** Setting this variable causes the ``status bar'' to be displayed on
28092818 ** the first line of the screen rather than near the bottom.
28102810- */
28112811- { "strict_mime", DT_BOOL, R_NONE, OPTSTRICTMIME, 1 },
28122812- /*
28132813- ** .pp
28142814- ** When unset, non MIME-compliant messages that doesn't have any
28152815- ** charset indication in ``Content-Type'' field can be displayed
28162816- ** (non MIME-compliant messages are often generated by old mailers
28172817- ** or buggy mailers like MS Outlook Express).
28182818- ** See also $$assumed_charset.
28192819- ** .pp
28202820- ** This option also replaces linear-white-space between encoded-word
28212821- ** and *text to a single space to prevent the display of MIME-encoded
28222822- ** ``Subject'' field from being devided into multiple lines.
28232819 */
28242820 { "strict_threads", DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTSTRICTTHREADS, 0 },
28252821 /*
+2-2
mutt.h
···370370 OPTHIDETHREADSUBJECT,
371371 OPTHIDETOPLIMITED,
372372 OPTHIDETOPMISSING,
373373+ OPTIGNORELWS,
373374 OPTIGNORELISTREPLYTO,
374375#ifdef USE_IMAP
375376 OPTIMAPCHECKSUBSCRIBED,
···428429 OPTSORTRE,
429430 OPTSPAMSEP,
430431 OPTSTATUSONTOP,
431431- OPTSTRICTMIME,
432432 OPTSTRICTTHREADS,
433433 OPTSUSPEND,
434434 OPTTEXTFLOWED,
···643643 * If NULL, filename is used
644644 * instead.
645645 */
646646- char *file_charset; /* charset of attached file */
646646+ char *charset; /* charset of attached file */
647647 CONTENT *content; /* structure used to store detailed info about
648648 * the content of the attachment. this is used
649649 * to determine what content-transfer-encoding
+4-4
parse.c
···217217 s++;
218218 for (i=0; *s && i < sizeof (buffer) - 1; i++, s++)
219219 {
220220- if (!option (OPTSTRICTMIME)) {
220220+ if (AssumedCharset && *AssumedCharset) {
221221 /* As iso-2022-* has a characer of '"' with non-ascii state,
222222 * ignore it. */
223223 if (*s == 0x1b && i < sizeof (buffer) - 2)
···402402 if (ct->type == TYPETEXT)
403403 {
404404 if (!(pc = mutt_get_parameter ("charset", ct->parameter)))
405405- mutt_set_parameter ("charset", option (OPTSTRICTMIME) ? "us-ascii" :
406406- (const char *) mutt_get_first_charset (AssumedCharset),
407407- &ct->parameter);
405405+ mutt_set_parameter ("charset", (AssumedCharset && *AssumedCharset) ?
406406+ (const char *) mutt_get_default_charset ()
407407+ : "us-ascii", &ct->parameter);
408408 }
409409410410}
+65-34
rfc2047.c
···8787 return n;
8888}
89899090+int convert_nonmime_string (char **ps)
9191+{
9292+ const char *c, *c1;
9393+9494+ for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
9595+ {
9696+ char *u = *ps;
9797+ char *s;
9898+ char *fromcode;
9999+ size_t m, n;
100100+ size_t ulen = mutt_strlen (*ps);
101101+ size_t slen;
102102+103103+ if (!u || !*u)
104104+ return 0;
105105+106106+ c1 = strchr (c, ':');
107107+ n = c1 ? c1 - c : mutt_strlen (c);
108108+ if (!n)
109109+ return 0;
110110+ fromcode = safe_malloc (n + 1);
111111+ strfcpy (fromcode, c, n + 1);
112112+ m = convert_string (u, ulen, fromcode, Charset, &s, &slen);
113113+ FREE (&fromcode);
114114+ if (m != (size_t)(-1))
115115+ {
116116+ FREE (ps); /* __FREE_CHECKED__ */
117117+ *ps = s;
118118+ return 0;
119119+ }
120120+ }
121121+ mutt_convert_string (ps,
122122+ (const char *)mutt_get_default_charset (AssumedCharset),
123123+ Charset, M_ICONV_HOOK_FROM);
124124+ return -1;
125125+}
126126+90127char *mutt_choose_charset (const char *fromcode, const char *charsets,
91128 char *u, size_t ulen, char **d, size_t *dlen)
92129{
···711748 return 0;
712749}
713750714714-/* return length of linear white space */
751751+/* return length of linear-white-space */
715752static size_t lwslen (const char *s, size_t n)
716753{
717754 const char *p = s;
···731768 return len;
732769}
733770734734-/* return length of linear white space : reverse */
771771+/* return length of linear-white-space : reverse */
735772static size_t lwsrlen (const char *s, size_t n)
736773{
737774 const char *p = s + n - 1;
···775812 if (!(p = find_encoded_word (s, &q)))
776813 {
777814 /* no encoded words */
778778- if (!option (OPTSTRICTMIME))
815815+ if (option (OPTIGNORELWS))
779816 {
780817 n = mutt_strlen (s);
781818 if (found_encoded && (m = lwslen (s, n)) != 0)
782819 {
783820 if (m != n)
784821 *d = ' ', d++, dlen--;
785785- n -= m, s += m;
822822+ s += m;
786823 }
787787- if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
788788- {
789789- char *t;
790790- size_t tlen;
824824+ }
825825+ if (AssumedCharset && *AssumedCharset)
826826+ {
827827+ char *t;
828828+ size_t tlen;
791829792792- t = safe_malloc (n + 1);
793793- strfcpy (t, s, n + 1);
794794- if (mutt_convert_nonmime_string (&t) == 0)
795795- {
796796- tlen = mutt_strlen (t);
797797- strncpy (d, t, tlen);
798798- d += tlen;
799799- }
800800- else
801801- {
802802- strncpy (d, s, n);
803803- d += n;
804804- }
805805- FREE (&t);
806806- break;
807807- }
830830+ n = mutt_strlen (s);
831831+ t = safe_malloc (n + 1);
832832+ strfcpy (t, s, n + 1);
833833+ convert_nonmime_string (&t);
834834+ tlen = mutt_strlen (t);
835835+ strncpy (d, t, tlen);
836836+ d += tlen;
837837+ FREE (&t);
838838+ break;
808839 }
809840 strncpy (d, s, dlen);
810841 d += dlen;
···814845 if (p != s)
815846 {
816847 n = (size_t) (p - s);
817817- /* ignore spaces between encoded words
818818- * and linear white spaces between encoded word and *text */
819819- if (!option (OPTSTRICTMIME))
848848+ /* ignore spaces between encoded word
849849+ * and linear-white-space between encoded word and *text */
850850+ if (option (OPTIGNORELWS))
820851 {
821852 if (found_encoded && (m = lwslen (s, n)) != 0)
822853 {
···838869 }
839870 else if (!found_encoded || strspn (s, " \t\r\n") != n)
840871 {
841841- if (n > dlen)
842842- n = dlen;
843843- memcpy (d, s, n);
844844- d += n;
845845- dlen -= n;
872872+ if (n > dlen)
873873+ n = dlen;
874874+ memcpy (d, s, n);
875875+ d += n;
876876+ dlen -= n;
846877 }
847847-848878 }
849879850880 rfc2047_decode_word (d, p, dlen);
···865895{
866896 while (a)
867897 {
868868- if (a->personal)
898898+ if (a->personal && ((strstr (a->personal, "=?") != NULL) ||
899899+ (AssumedCharset && *AssumedCharset)))
869900 rfc2047_decode (&a->personal);
870901#ifdef EXACT_ADDRESS
871902 if (a->val && strstr (a->val, "=?") != NULL)