diff options
author | Eduardo Chappa <chappa@washington.edu> | 2016-09-29 09:24:39 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2016-09-29 09:24:39 -0600 |
commit | 174c8ccf0d4aae97fc5858d082c58fd5b23402a0 (patch) | |
tree | 081225d91920574b536b687f7cb14c113a91e7b8 | |
parent | 9675e266e051c74f479ecb9e1ee4246e98fd8dad (diff) | |
download | alpine-174c8ccf0d4aae97fc5858d082c58fd5b23402a0.tar.xz |
* Alpine will include attachments when forwarding some
multipart/alternative messages for which it did not use to include
attachments.
-rw-r--r-- | pith/pine.hlp | 6 | ||||
-rw-r--r-- | pith/reply.c | 93 | ||||
-rw-r--r-- | pith/reply.h | 1 |
3 files changed, 99 insertions, 1 deletions
diff --git a/pith/pine.hlp b/pith/pine.hlp index fca474c1..ea684a73 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 171 2016-09-28 20:29:17 +Alpine Commit 172 2016-09-29 09:24:36 ============= h_news ================= <HTML> <HEAD> @@ -191,6 +191,10 @@ Additions include: <LI> Alpine builds with any version bigger or equal to 1.0.0c, including version 1.1.0, as well as LibreSSL. + <LI> Alpine will include attachments when forwarding some + multipart/alternative messages for which it did not use to include + attachments. + <LI> New configuration option <a href="h_config_alt_reply_menu"><!--#echo var="FEAT_alternate-reply-menu"--></a> which adds more ways to control features and variables when you diff --git a/pith/reply.c b/pith/reply.c index fac2348b..7ceb31f8 100644 --- a/pith/reply.c +++ b/pith/reply.c @@ -3580,6 +3580,94 @@ bail_out: return(file); } +/* special handling for messages that contain a mixed part in the + * multipart alternative section. + */ +BODY * +forward_multi_alt_mixed(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, + long int msgno, char *sect_prefix, void *msgtext, gf_io_t pc, int flags) +{ +#define FWDTMPLEN 256 + BODY *body = NULL, *text_body = NULL; + PART *part = NULL; + char prefix_buf[FWDTMPLEN]; + char *new_charset = NULL; + int partnum; + char *section, sect_buf[256]; + int forward_raw_body = 0; + + if(orig_body + && orig_body->type == TYPEMULTIPART + && orig_body->subtype + && !strucmp(orig_body->subtype, "alternative")) + for(part = orig_body->nested.part, partnum = 1; + part; + part = part->next, partnum++) + if(part->body.type == TYPEMULTIPART + && part->body.subtype + && !strucmp(part->body.subtype, "MIXED")) + break; + + if(part == NULL) return NULL; + + snprintf(prefix_buf, sizeof(prefix_buf), "%.*s%s%s%d", + FWDTMPLEN/2, sect_prefix ? sect_prefix : "", + sect_prefix ? "." : "", flags & FWD_NESTED ? "1." : "", + partnum); + prefix_buf[sizeof(prefix_buf)-1] = '\0'; + + if(ps_global->full_header == 2 + && F_ON(F_ENABLE_FULL_HDR_AND_TEXT, ps_global)) + forward_raw_body = 1; + if(sp_expunge_count(stream)) + return(NULL); + + if(sect_prefix && forward_raw_body == 0) + snprintf(section = sect_buf, sizeof(sect_buf), "%s.1", sect_prefix); + else if(sect_prefix && forward_raw_body) + section = sect_prefix; + else if(!sect_prefix && forward_raw_body) + section = NULL; + else + section = "1"; + sect_buf[sizeof(sect_buf)-1] = '\0'; + + body = copy_body(NULL, &part->body); + + /*--- The text part of the message ---*/ + if(!body->nested.part){ + q_status_message(SM_ORDER | SM_DING, 3, 6, + "Error referencing body part 1"); + mail_free_body(&body); + } + else if(body->nested.part->body.type == TYPETEXT) { + char *new_charset = NULL; + + /*--- The first part is text ----*/ + text_body = &body->nested.part->body; + text_body->contents.text.data = msgtext; + if(text_body->subtype && strucmp(text_body->subtype, "Plain")){ + /* this text is going to the composer, it should be Plain */ + fs_give((void **)&text_body->subtype); + text_body->subtype = cpystr("PLAIN"); + } + if(!(flags & FWD_ANON)){ + forward_delimiter(pc); + reply_forward_header(stream, msgno, + sect_prefix, env, pc, ""); + } + + if(!(get_body_part_text(stream, &part->body, + msgno, section, 0L, pc, + NULL, &new_charset, GBPT_NONE) + && fetch_contents(stream, msgno, prefix_buf, body))) + mail_free_body(&body); + else if(new_charset) + set_parameter(&text_body->parameter, "charset", new_charset); + } + return(body); +} + /*---------------------------------------------------------------------- Build the body for the multipart/alternative part @@ -3600,6 +3688,11 @@ forward_multi_alt(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *ori char *new_charset = NULL; int partnum, bestpartnum; + /* try multipart mixed first */ + if((body = forward_multi_alt_mixed(stream, env, orig_body, + msgno, sect_prefix, msgtext, pc, flags)) != NULL) + return body; + if(ps_global->force_prefer_plain || (!ps_global->force_no_prefer_plain && F_ON(F_PREFER_PLAIN_TEXT, ps_global))){ diff --git a/pith/reply.h b/pith/reply.h index caeb352b..43d5f56e 100644 --- a/pith/reply.h +++ b/pith/reply.h @@ -102,6 +102,7 @@ int sigdashes_are_present(char *); char *signature_path(char *, char *, size_t); char *simple_read_remote_file(char *, char *); BODY *forward_multi_alt(MAILSTREAM *, ENVELOPE *, BODY *, long, char *, void *, gf_io_t, int); +BODY *forward_multi_alt_mixed(MAILSTREAM *, ENVELOPE *, BODY *, long, char *, void *, gf_io_t, int); int same_subject(char *, char *s); |