From: Thomas Roessler Date: Mon, 27 Nov 2000 13:14:28 +0000 (+0000) Subject: Make sure edit-type works without a segmentation fault from the X-Git-Tag: mutt-1-3-13-rel~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32a08cd650d8998652d4852814e31900c5876923;p=mutt Make sure edit-type works without a segmentation fault from the receive-attach menu. --- diff --git a/attach.h b/attach.h index 4743a278..c3561306 100644 --- a/attach.h +++ b/attach.h @@ -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 *); diff --git a/commands.c b/commands.c index cdf50da1..4ca832b5 100644 --- a/commands.c +++ b/commands.c @@ -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) { diff --git a/compose.c b/compose.c index a82ddc5a..c43fa321 100644 --- a/compose.c +++ b/compose.c @@ -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; diff --git a/curs_main.c b/curs_main.c index 34e55b53..6e6816a5 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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) { diff --git a/protos.h b/protos.h index f254ecf6..02d047b2 100644 --- a/protos.h +++ b/protos.h @@ -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 *, ...); diff --git a/recvattach.c b/recvattach.c index 1c99d2c0..27c04e4c 100644 --- a/recvattach.c +++ b/recvattach.c @@ -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: