mutt_message("NeoMutt %s%s (%s)", PACKAGE_VERSION, GitVer, MUTT_VERSION);
}
-void mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp)
+/*
+ * Returns:
+ * 1 when a structural change is made.
+ * recvattach requires this to know when to regenerate the actx.
+ * 0 otherwise.
+ */
+int mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp)
{
char buf[LONG_STRING];
char obuf[LONG_STRING];
short charset_changed = 0;
short type_changed = 0;
+ short structure_changed = 0;
cp = mutt_get_parameter("charset", b->parameter);
strfcpy(charset, NONULL(cp), sizeof(charset));
}
if (mutt_get_field("Content-Type: ", buf, sizeof(buf), 0) != 0 || buf[0] == 0)
- return;
+ return 0;
/* clean up previous junk */
mutt_free_parameter(&b->parameter);
b->force_charset |= charset_changed ? 1 : 0;
if (!is_multipart(b) && b->parts)
+ {
+ structure_changed = 1;
mutt_free_body(&b->parts);
+ }
if (!mutt_is_message_type(b->type, b->subtype) && b->hdr)
{
+ structure_changed = 1;
b->hdr->content = NULL;
mutt_free_header(&b->hdr);
}
- if (fp && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
+ if (fp && !b->parts && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
+ {
+ structure_changed = 1;
mutt_parse_part(fp, b);
+ }
if (WithCrypto && h)
{
h->security |= crypt_query(b);
}
+
+ return structure_changed;
}
static int _mutt_check_traditional_pgp(struct Header *h, int *redraw)
void mutt_default_save(char *path, size_t pathlen, struct Header *hdr);
void mutt_display_address(struct Envelope *env);
void mutt_draw_statusline(int cols, const char *buf, int buflen);
-void mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp);
+int mutt_edit_content_type (struct Header *h, struct Body *b, FILE *fp);
void mutt_edit_file(const char *editor, const char *data);
void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
char *fcc, size_t fcclen);
return rv;
}
+static void recvattach_edit_content_type(struct AttachCtx *actx,
+ struct Menu *menu, struct Header *hdr)
+{
+ if (mutt_edit_content_type(hdr, CURATTACH->content, CURATTACH->fp) == 1)
+ {
+ /* The mutt_update_recvattach_menu() will overwrite any changes
+ * made to a decrypted CURATTACH->content, so warn the user. */
+ if (CURATTACH->decrypted)
+ {
+ mutt_message(
+ _("Structural changes to decrypted attachments are not supported"));
+ mutt_sleep(1);
+ }
+ /* Editing the content type can rewrite the body structure. */
+ for (int i = 0; i < actx->idxlen; i++)
+ actx->idx[i]->content = NULL;
+ mutt_actx_free_entries(actx);
+ mutt_update_recvattach_menu(actx, menu, 1);
+ }
+}
+
int mutt_attach_display_loop(struct Menu *menu, int op, struct Header *hdr,
struct AttachCtx *actx, int recv)
{
immediately */
mutt_edit_content_type(hdr, CURATTACH->content, CURATTACH->fp);
if (recv)
- {
- /* Editing the content type can rewrite the body structure. */
- for (int i = 0; i < actx->idxlen; i++)
- actx->idx[i]->content = NULL;
- mutt_actx_free_entries(actx);
- mutt_update_recvattach_menu(actx, menu, 1);
- }
+ recvattach_edit_content_type(actx, menu, hdr);
+ else
+ mutt_edit_content_type(hdr, CURATTACH->content, CURATTACH->fp);
+
+ menu->redraw |= REDRAW_INDEX;
op = OP_VIEW_ATTACH;
break;
/* functions which are passed through from the pager */
struct Menu *menu = NULL;
struct Body *cur = NULL;
struct Message *msg = NULL;
- FILE *fp = NULL;
struct AttachCtx *actx = NULL;
int flags = 0;
int op = OP_NULL;
#ifdef USE_NNTP
case OP_FORWARD_TO_GROUP:
CHECK_ATTACH;
- mutt_attach_forward(fp, hdr, actx, menu->tagprefix ? NULL : CURATTACH->content, SENDNEWS);
+ mutt_attach_forward(CURATTACH->fp, hdr, actx, menu->tagprefix ? NULL : CURATTACH->content, SENDNEWS);
menu->redraw = REDRAW_FULL;
break;
query_quadoption(OPT_FOLLOW_UP_TO_POSTER,
_("Reply by mail as poster prefers?")) != MUTT_YES)
{
- mutt_attach_reply(fp, hdr, actx, menu->tagprefix ? NULL : CURATTACH->content,
+ mutt_attach_reply(CURATTACH->fp, hdr, actx, menu->tagprefix ? NULL : CURATTACH->content,
SENDNEWS | SENDREPLY);
menu->redraw = REDRAW_FULL;
break;
break;
case OP_EDIT_TYPE:
- mutt_edit_content_type(hdr, CURATTACH->content, fp);
- /* Editing the content type can rewrite the body structure. */
- for (i = 0; i < actx->idxlen; i++)
- actx->idx[i]->content = NULL;
- mutt_actx_free_entries(actx);
- mutt_update_recvattach_menu(actx, menu, 1);
+ recvattach_edit_content_type(actx, menu, hdr);
+ menu->redraw |= REDRAW_INDEX;
break;
case OP_EXIT: