should work again, now.
pretty, i+1);
if((r = mutt_yesorno(msg, M_YES)) == M_YES)
- mutt_update_encoding(idx[i]->content);
+ mutt_update_encoding(idx[i]->content, NULL);
else if(r == -1)
return -1;
}
if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS))
{
mutt_edit_file (Editor, msg->content->filename);
- mutt_update_encoding (msg->content);
+ mutt_update_encoding (msg->content, NULL);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
break;
}
code below to regenerate the index array */
mutt_builtin_editor (msg->content->filename, msg, cur);
}
- mutt_update_encoding (msg->content);
+ mutt_update_encoding (msg->content, NULL);
/* attachments may have been added */
if (idxlen && idx[idxlen - 1]->content->next)
case OP_COMPOSE_UPDATE_ENCODING:
CHECK_COUNT;
- if(menu->tagprefix)
+ if (menu->tagprefix)
{
BODY *top;
- for(top = msg->content; top; top = top->next)
+ for (top = msg->content; top; top = top->next)
{
- if(top->tagged)
- mutt_update_encoding(top);
+ if (top->tagged)
+ mutt_update_encoding (top, NULL);
}
menu->redraw = REDRAW_FULL;
}
else
{
- mutt_update_encoding(idx[menu->current]->content);
+ mutt_update_encoding(idx[menu->current]->content, NULL);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
}
break;
mutt_edit_content_type (NULL, idx[menu->current]->content);
/* this may have been a change to text/something */
- mutt_update_encoding (idx[menu->current]->content);
+ mutt_update_encoding (idx[menu->current]->content, NULL);
menu->redraw = REDRAW_CURRENT;
}
CHECK_COUNT;
mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor),
idx[menu->current]->content->filename);
- mutt_update_encoding (idx[menu->current]->content);
+ mutt_update_encoding (idx[menu->current]->content, NULL);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
break;
if (mutt_compose_attachment (idx[menu->current]->content))
{
- mutt_update_encoding (idx[menu->current]->content);
+ mutt_update_encoding (idx[menu->current]->content, NULL);
menu->redraw = REDRAW_FULL;
}
}
CHECK_COUNT;
if (mutt_edit_attachment (idx[menu->current]->content))
{
- mutt_update_encoding (idx[menu->current]->content);
+ mutt_update_encoding (idx[menu->current]->content, NULL);
menu->redraw = REDRAW_FULL;
}
break;
mutt_error (_("Error running \"%s\"!"), buf);
else
{
- mutt_update_encoding (msg->content);
+ mutt_update_encoding (msg->content, NULL);
menu->redraw |= REDRAW_STATUS;
}
break;
att->subtype = safe_strdup ("pgp-keys");
snprintf (buff, sizeof (buff), _("PGP Key %s."), tmp);
att->description = safe_strdup (buff);
- mutt_update_encoding (att);
+ mutt_update_encoding (att, NULL);
stat (tempf, &sb);
att->length = sb.st_size;
void mutt_FormatString (char *, size_t, const char *, format_t *, unsigned long, format_flag);
void mutt_parse_content_type (char *, BODY *);
-void mutt_update_encoding (BODY *a);
void mutt_generate_boundary (PARAMETER **);
void mutt_set_parameter (const char *, const char *, PARAMETER **);
char *mutt_find_hook (int, const char *);
char *mutt_gecos_name (char *, size_t, struct passwd *);
char *mutt_gen_msgid (void);
+char *mutt_get_body_charset (char *, size_t, BODY *);
char *mutt_get_name (ADDRESS *);
char *mutt_get_parameter (const char *, PARAMETER *);
-char *mutt_get_send_charset (char *, size_t, BODY *, short);
#ifdef HAVE_PGP
char *mutt_pgp_hook (ADDRESS *);
#endif /* HAVE_PGP */
void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
void mutt_set_followup_to (ENVELOPE *);
-void mutt_set_body_charset (BODY *, const char *);
void mutt_shell_escape (void);
void mutt_show_error (void);
void mutt_signal_init (void);
void mutt_tag_set_flag (int, int);
void mutt_unblock_signals (void);
void mutt_unblock_signals_system (int);
-void mutt_update_encoding (BODY *a);
+void mutt_update_encoding (BODY *a, CONTENT *info);
void mutt_update_tree (ATTACHPTR **, short);
void mutt_version (void);
void mutt_view_attachments (HEADER *);
{
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
if (mutt_is_text_type (aptr->content->type, aptr->content->subtype) &&
- mutt_get_send_charset (charset, sizeof (charset), aptr->content, 0))
+ mutt_get_body_charset (charset, sizeof (charset), aptr->content))
snprintf (dest, destlen, fmt, charset);
else
snprintf (dest, destlen, fmt, "");
}
else if (!mutt_is_text_type (aptr->content->type, aptr->content->subtype) ||
- !mutt_get_send_charset (charset, sizeof (charset), aptr->content, 0))
+ !mutt_get_body_charset (charset, sizeof (charset), aptr->content))
optional = 0;
break;
case 'c':
{
mutt_unlink (body->filename);
mutt_rename_file (tfile, body->filename);
- mutt_update_encoding (body);
+ mutt_update_encoding (body, NULL);
mutt_message _("Attachment filtered.");
}
}
utime (msg->content->filename, &utim);
}
- mutt_update_encoding (msg->content);
+ mutt_update_encoding (msg->content, NULL);
/* If the this isn't a text message, look for a mailcap edit command */
if(! (flags & SENDKEY))
}
- mutt_update_encoding (msg->content);
+ mutt_update_encoding (msg->content, NULL);
if (! (flags & (SENDMAILX | SENDBATCH)))
{
}
if (a->type == TYPETEXT && (!a->noconv))
- fc = fgetconv_open (fpin, Charset, mutt_get_send_charset (send_charset, sizeof (send_charset), a, 1));
+ fc = fgetconv_open (fpin, Charset, mutt_get_body_charset (send_charset, sizeof (send_charset), a));
else
fc = fgetconv_open (fpin, 0, 0);
mutt_set_parameter ("boundary", rs, parm);
}
-
typedef struct
{
int from;
CONTENT_STATE;
-static void update_content_info(CONTENT *info, CONTENT_STATE *s, char *d, size_t dlen)
+static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_t dlen)
{
int from = s->from;
int whitespace = s->whitespace;
return ret;
}
-/* Analyze the contents of a file to determine which MIME encoding to use.
+/*
+ * Analyze the contents of a file to determine which MIME encoding to use.
* Also set the body charset, sometimes, or not.
*/
CONTENT *mutt_get_content_info (const char *fname, BODY *b)
{
if (!chs)
mutt_set_parameter ("charset", tocode, &b->parameter);
- safe_free (&fromcode);
- safe_free (&tocode);
+ safe_free ((void **) &fromcode);
+ safe_free ((void **) &tocode);
safe_fclose (&fp);
return info;
}
safe_fclose (&fp);
if (b != NULL && b->type == TYPETEXT && (!b->noconv))
- mutt_set_parameter ("charset",
- info->hibin ? "unknown-8bit" : "us-ascii",
+ mutt_set_parameter ("charset", info->hibin ? "unknown-8bit" : "us-ascii",
&b->parameter);
return info;
}
a->length = sb.st_size;
- mutt_update_encoding (a);
+ mutt_update_encoding (a, NULL);
if (a->encoding == ENC8BIT)
a->encoding = ENCQUOTEDPRINTABLE;
else if(a->encoding == ENCBINARY)
}
}
-static const char *get_text_charset (char *d, size_t dlen, BODY *b, CONTENT *info)
-{
- char send_charset[SHORT_STRING];
- char *chsname;
- char *p;
-
- chsname = mutt_get_send_charset (send_charset, sizeof (send_charset), b, 1);
-
- /* if charset is unknown assume low bytes are ascii compatible */
-
- if ((chsname == NULL || mutt_strcasecmp (chsname, "us-ascii") == 0)
- && info->hibin)
- p = "unknown-8bit";
- else if (info->hibin || !strcasecmp (chsname, "utf-7"))
- p = chsname;
- else if (info->lobin && !strncasecmp (chsname, "iso-2022-jp", 11))
- p = chsname;
- else
- p = "us-ascii";
-
- strfcpy (d, p, dlen);
- return d;
-}
-
/* determine which Content-Transfer-Encoding to use */
static void mutt_set_encoding (BODY *b, CONTENT *info)
{
if (b->type == TYPETEXT)
{
- char *chsname = mutt_get_send_charset (send_charset, sizeof (send_charset), b, 1);
+ 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)))
b->encoding = ENCQUOTEDPRINTABLE;
else if (info->hibin)
a->stamp = time(NULL);
}
-/* Get the character set which is to be used for sending */
+/* Get a body's character set */
-char *mutt_get_send_charset (char *d, size_t dlen, BODY *b, short f)
+char *mutt_get_body_charset (char *d, size_t dlen, BODY *b)
{
char *p = NULL;
if (b)
p = mutt_get_parameter ("charset", b->parameter);
- /* override the special "us-ascii" and "unknown-8bit" character sets */
- if (!p || (f && (!mutt_strcasecmp (p, "us-ascii") || !mutt_strcasecmp (p, "unknown-8bit"))))
- {
- if (SendCharset && *SendCharset)
- {
- p = strrchr (SendCharset, ':');
- p = p ? p + 1 : SendCharset;
- }
- else if (Charset)
- p = Charset;
- }
-
if (p)
- {
strfcpy (d, NONULL(p), dlen);
- return d;
- }
-
- /* something is seriously wrong. */
- return NULL;
-}
-
-/* set a body structure's character set */
-
-void mutt_set_body_charset(BODY *b, const char *chs)
-{
- char send_charset[SHORT_STRING];
-
- if(b->type != TYPETEXT)
- return;
-
- if(!chs && !(chs = mutt_get_send_charset(send_charset, sizeof(send_charset), NULL, 1)))
- return;
+ else
+ strfcpy (d, "us-ascii", dlen);
- mutt_set_parameter ("charset", chs, &b->parameter);
+ return d;
}
/* Assumes called from send mode where BODY->filename points to actual file */
-void mutt_update_encoding (BODY *a)
+void mutt_update_encoding (BODY *a, CONTENT *info)
{
- CONTENT *info;
+ char chsbuff[STRING];
+
+ /* override noconv when it's us-ascii */
+ if (!mutt_strcasecmp (mutt_get_body_charset (chsbuff, sizeof (chsbuff), a), "us-ascii"))
+ a->noconv = 0;
- /* Previous value is usually wrong, apparently. */
- if (!a->force_charset)
- mutt_set_parameter ("charset", 0, &a->parameter);
+ if (!a->force_charset && !a->noconv)
+ mutt_set_parameter ("charset", NULL, &a->parameter);
- if ((info = mutt_get_content_info (a->filename, a)) == NULL)
+ if (!info && (info = mutt_get_content_info (a->filename, a)) == NULL)
return;
mutt_set_encoding (a, info);
#ifdef HAVE_PGP
body->hdr->pgp = pgp;
#endif /* HAVE_PGP */
- mutt_update_encoding (body);
+ mutt_update_encoding (body, NULL);
body->parts = body->hdr->content;
fclose(fp);
BODY *att;
CONTENT *info;
char buf[SHORT_STRING];
- char chsbuf[SHORT_STRING];
int n;
att = mutt_new_body ();
}
}
- /* XXX - just call mutt_update_encoding? -tlr */
-
- mutt_set_encoding (att, info);
- mutt_stamp_attachment(att);
-
- if (att->type == TYPETEXT)
- mutt_set_body_charset(att, get_text_charset(chsbuf, sizeof (chsbuf), att, info));
-
- att->content = info;
-
+ mutt_update_encoding (att, info);
return (att);
}