mutt_message (_("Character set changed to %s."),
mutt_get_parameter ("charset", b->parameter));
- b->force_charset |= charset_changed;
+ b->force_charset |= charset_changed ? 1 : 0;
if (!is_multipart (b) && b->parts)
mutt_free_body (&b->parts);
pretty, i+1);
if((r = mutt_yesorno(msg, M_YES)) == M_YES)
- mutt_update_encoding(idx[i]->content, NULL);
+ mutt_update_encoding(idx[i]->content);
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, NULL);
+ mutt_update_encoding (msg->content);
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, NULL);
+ mutt_update_encoding (msg->content);
/* attachments may have been added */
if (idxlen && idx[idxlen - 1]->content->next)
for (top = msg->content; top; top = top->next)
{
if (top->tagged)
- mutt_update_encoding (top, NULL);
+ mutt_update_encoding (top);
}
menu->redraw = REDRAW_FULL;
}
else
{
- mutt_update_encoding(idx[menu->current]->content, NULL);
+ mutt_update_encoding(idx[menu->current]->content);
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, NULL);
+ mutt_update_encoding (idx[menu->current]->content);
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, NULL);
+ mutt_update_encoding (idx[menu->current]->content);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
break;
if (mutt_compose_attachment (idx[menu->current]->content))
{
- mutt_update_encoding (idx[menu->current]->content, NULL);
+ mutt_update_encoding (idx[menu->current]->content);
menu->redraw = REDRAW_FULL;
}
}
CHECK_COUNT;
if (mutt_edit_attachment (idx[menu->current]->content))
{
- mutt_update_encoding (idx[menu->current]->content, NULL);
+ mutt_update_encoding (idx[menu->current]->content);
menu->redraw = REDRAW_FULL;
}
break;
mutt_error (_("Error running \"%s\"!"), buf);
else
{
- mutt_update_encoding (msg->content, NULL);
+ mutt_update_encoding (msg->content);
menu->redraw |= REDRAW_STATUS;
}
break;
void mutt_set_parameter (const char *attribute, const char *value, PARAMETER **p)
{
PARAMETER *q;
+
+ if (!value)
+ {
+ mutt_delete_parameter (attribute, p);
+ return;
+ }
+
for(q = *p; q; q = q->next)
{
if (mutt_strcasecmp (attribute, q->attribute) == 0)
*p = q;
}
-
-
+void mutt_delete_parameter (const char *attribute, PARAMETER **p)
+{
+ PARAMETER *q;
+
+ for (q = *p; q; p = &q->next, q = q->next)
+ {
+ if (mutt_strcasecmp (attribute, q->attribute) == 0)
+ {
+ *p = q->next;
+ q->next = NULL;
+ mutt_free_parameter (&q);
+ return;
+ }
+ }
+}
/* returns 1 if Mutt can't display this type of data, 0 otherwise */
int mutt_needs_mailcap (BODY *m)
att->subtype = safe_strdup ("pgp-keys");
snprintf (buff, sizeof (buff), _("PGP Key %s."), tmp);
att->description = safe_strdup (buff);
- mutt_update_encoding (att, NULL);
+ mutt_update_encoding (att);
stat (tempf, &sb);
att->length = sb.st_size;
newhdr->content = mutt_remove_multipart (newhdr->content);
s.fpin = bfp;
- s.flags = M_CHARCONV;
/* create temporary files for all attachments */
for (b = newhdr->content; b; b = b->next)
/* avoid Content-Disposition: header with temporary filename */
b->use_disp = 0;
+ if (b->type == TYPETEXT &&
+ !mutt_strcasecmp ("yes", mutt_get_parameter ("x-mutt-noconv", b->parameter)))
+ {
+ s.flags &= ~M_CHARCONV;
+ b->noconv = 1;
+ }
+ else
+ {
+ s.flags |= M_CHARCONV;
+ b->noconv = 0;
+ }
+
+ mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
+
mutt_adv_mktemp (file, sizeof(file));
-
if ((s.fpout = safe_fopen (file, "w")) == NULL)
goto bail;
- mutt_decode_attachment (b, &s);
+ mutt_decode_attachment (b, &s);
+
if (safe_fclose (&s.fpout) != 0)
goto bail;
mutt_str_replace (&b->filename, file);
b->unlink = 1;
- if (b->type == TYPETEXT)
- b->noconv = 0;
-
mutt_stamp_attachment (b);
mutt_free_body (&b->parts);
void mutt_FormatString (char *, size_t, const char *, format_t *, unsigned long, format_flag);
void mutt_parse_content_type (char *, BODY *);
void mutt_generate_boundary (PARAMETER **);
+void mutt_delete_parameter (const char *attribute, PARAMETER **p);
void mutt_set_parameter (const char *, const char *, PARAMETER **);
+
FILE *mutt_open_read (const char *, pid_t *);
void set_quadoption (int, int);
void mutt_tag_set_flag (int, int);
void mutt_unblock_signals (void);
void mutt_unblock_signals_system (int);
-void mutt_update_encoding (BODY *a, CONTENT *info);
+void mutt_update_encoding (BODY *a);
void mutt_update_tree (ATTACHPTR **, short);
void mutt_version (void);
void mutt_view_attachments (HEADER *);
{
mutt_unlink (body->filename);
mutt_rename_file (tfile, body->filename);
- mutt_update_encoding (body, NULL);
+ mutt_update_encoding (body);
mutt_message _("Attachment filtered.");
}
}
utime (msg->content->filename, &utim);
}
- mutt_update_encoding (msg->content, NULL);
+ mutt_update_encoding (msg->content);
/* If the this isn't a text message, look for a mailcap edit command */
if(! (flags & SENDKEY))
}
- mutt_update_encoding (msg->content, NULL);
+ mutt_update_encoding (msg->content);
if (! (flags & (SENDMAILX | SENDBATCH)))
{
info = safe_calloc (1, sizeof (CONTENT));
memset (&state, 0, sizeof (state));
- if (b != NULL && b->type == TYPETEXT && (!b->noconv))
+ if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
{
char *chs = mutt_get_parameter ("charset", b->parameter);
if (Charset && (chs || SendCharset) &&
safe_fclose (&fp);
- if (b != NULL && b->type == TYPETEXT && (!b->noconv))
+ if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
mutt_set_parameter ("charset", info->hibin ? "unknown-8bit" : "us-ascii",
&b->parameter);
}
a->length = sb.st_size;
- mutt_update_encoding (a, NULL);
+ mutt_update_encoding (a);
if (a->encoding == ENC8BIT)
a->encoding = ENCQUOTEDPRINTABLE;
else if(a->encoding == ENCBINARY)
/* Assumes called from send mode where BODY->filename points to actual file */
-void mutt_update_encoding (BODY *a, CONTENT *info)
+void mutt_update_encoding (BODY *a)
{
+ CONTENT *info;
char chsbuff[STRING];
/* override noconv when it's us-ascii */
a->noconv = 0;
if (!a->force_charset && !a->noconv)
- mutt_set_parameter ("charset", NULL, &a->parameter);
+ mutt_delete_parameter ("charset", &a->parameter);
- if (!info && (info = mutt_get_content_info (a->filename, a)) == NULL)
+ if ((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, NULL);
+ mutt_update_encoding (body);
body->parts = body->hdr->content;
fclose(fp);
}
}
- mutt_update_encoding (att, info);
+ mutt_update_encoding (att);
return (att);
}
return (top);
}
+static void set_noconv_flags (BODY *b, short flag)
+{
+ for(; b; b = b->next)
+ {
+ if (b->type == TYPEMESSAGE || b->type == TYPEMULTIPART)
+ set_noconv_flags (b->parts, flag);
+ else if (b->type == TYPETEXT && b->noconv)
+ {
+ if (flag)
+ mutt_set_parameter ("x-mutt-noconv", "yes", &b->parameter);
+ else
+ mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
+ }
+ }
+}
+
int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc)
{
CONTEXT f;
FILE *tempfp = NULL;
int r;
+ if (post)
+ set_noconv_flags (hdr->content, 1);
+
if (mx_open_mailbox (path, M_APPEND | M_QUIET, &f) == NULL)
{
dprint (1, (debugfile, "mutt_write_fcc(): unable to open mailbox %s in append-mode, aborting.\n",
mx_close_message (&msg);
mx_close_mailbox (&f, NULL);
+ if (post)
+ set_noconv_flags (hdr->content, 0);
+
return r;
}