Commit 32a08cd6 authored by Thomas Roessler's avatar Thomas Roessler

Make sure edit-type works without a segmentation fault from the

receive-attach menu.
parent bbf94221
......@@ -24,7 +24,7 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr);
void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter);
void mutt_print_attachment_list (FILE *fp, int tag, BODY *top);
void mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
ATTACHPTR **idx, short idxlen);
BODY *cur, ATTACHPTR **idx, short *idxlen, short *idxmax);
void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
......
......@@ -770,7 +770,7 @@ void mutt_version (void)
mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
}
void mutt_edit_content_type (HEADER *h, BODY *b)
void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
{
char buf[LONG_STRING];
char obuf[LONG_STRING];
......@@ -834,6 +834,9 @@ void mutt_edit_content_type (HEADER *h, BODY *b)
mutt_free_header (&b->hdr);
}
if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
mutt_parse_part (fp, b);
#ifdef HAVE_PGP
if (h)
{
......
......@@ -906,7 +906,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
case OP_EDIT_TYPE:
CHECK_COUNT;
{
mutt_edit_content_type (NULL, idx[menu->current]->content);
mutt_edit_content_type (NULL, idx[menu->current]->content, NULL);
/* this may have been a change to text/something */
mutt_update_encoding (idx[menu->current]->content);
......@@ -1112,7 +1112,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
case OP_VIEW_ATTACH:
case OP_DISPLAY_HEADERS:
CHECK_COUNT;
mutt_attach_display_loop (menu, op, NULL, NULL, idx, idxlen);
mutt_attach_display_loop (menu, op, NULL, NULL, NULL, idx, &idxlen, NULL);
menu->redraw = REDRAW_FULL;
break;
......
......@@ -1054,7 +1054,7 @@ int mutt_index_menu (void)
CHECK_MSGCOUNT;
CHECK_ATTACH;
mutt_edit_content_type (CURHDR, CURHDR->content);
mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
/* if we were in the pager, redisplay the message */
if (menu->menu == MENU_PAGER)
{
......
......@@ -151,7 +151,7 @@ void mutt_decode_attachment (BODY *, STATE *);
void mutt_default_save (char *, size_t, HEADER *);
void mutt_display_address (ENVELOPE *);
void mutt_display_sanitize (char *);
void mutt_edit_content_type (HEADER *, BODY *);
void mutt_edit_content_type (HEADER *, BODY *, FILE *);
void mutt_edit_file (const char *, const char *);
void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
void mutt_curses_error (const char *, ...);
......
......@@ -682,9 +682,28 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top)
print_attachment_list (fp, tag, top, &state);
}
ATTACHPTR **mutt_update_attach_index (BODY *cur, ATTACHPTR **idx,
short *idxlen, short *idxmax,
MUTTMENU *menu)
{
*idxlen = 0;
idx = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
menu->max = *idxlen;
menu->data = idx;
if (menu->current >= menu->max)
menu->current = menu->max - 1;
menu_check_recenter (menu);
menu->redraw |= REDRAW_INDEX;
return idx;
}
void
mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
ATTACHPTR **idx, short idxlen)
mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
BODY *cur, ATTACHPTR **idx, short *idxlen, short *idxmax)
{
#if 0
int old_optweed = option (OPTWEED);
......@@ -701,7 +720,7 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
case OP_VIEW_ATTACH:
op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
hdr, idx, idxlen);
hdr, idx, *idxlen);
break;
case OP_NEXT_ENTRY:
......@@ -727,8 +746,10 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
case OP_EDIT_TYPE:
/* when we edit the content-type, we should redisplay the attachment
immediately */
mutt_edit_content_type (hdr, idx[menu->current]->content);
op = OP_VIEW_ATTACH;
mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
if (idxmax)
mutt_update_attach_index (cur, idx, idxlen, idxmax, menu);
op = OP_VIEW_ATTACH;
break;
default:
op = OP_NULL;
......@@ -752,6 +773,8 @@ static const char *Function_not_permitted = N_("Function not permitted in attach
break; \
}
void mutt_view_attachments (HEADER *hdr)
{
......@@ -807,24 +830,23 @@ void mutt_view_attachments (HEADER *hdr)
cur = hdr->content;
}
idx = mutt_gen_attach_list (cur, -1, idx, &idxlen, &idxmax, 0, 0);
menu = mutt_new_menu ();
menu->max = idxlen;
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
menu->menu = MENU_ATTACH;
menu->title = _("Attachments");
menu->data = idx;
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
idx = mutt_update_attach_index (cur, idx, &idxlen, &idxmax, menu);
FOREVER
{
switch (op = mutt_menuLoop (menu))
{
case OP_DISPLAY_HEADERS:
case OP_VIEW_ATTACH:
mutt_attach_display_loop (menu, op, fp, hdr, idx, idxlen);
mutt_attach_display_loop (menu, op, fp, hdr, cur, idx, &idxlen, &idxmax);
menu->redraw = REDRAW_FULL;
break;
......@@ -998,8 +1020,8 @@ void mutt_view_attachments (HEADER *hdr)
break;
case OP_EDIT_TYPE:
mutt_edit_content_type (hdr, idx[menu->current]->content);
menu->redraw = REDRAW_CURRENT;
mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
mutt_update_attach_index (cur, idx, &idxlen, &idxmax, menu);
break;
case OP_EXIT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment