Skip to content

Commit

Permalink
send: preserve multipart email body when crypt fails
Browse files Browse the repository at this point in the history
  • Loading branch information
dcpurton authored and flatcap committed Jan 14, 2022
1 parent 892c1f6 commit 8f895e8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions send/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,8 @@ static int postpone_message(struct Email *e_post, struct Email *e_cur,
{
if (mutt_autocrypt_set_sign_as_default_key(e_post))
{
e_post->body = mutt_remove_multipart(e_post->body);
if (mutt_istr_equal(e_post->body->subtype, "mixed"))
e_post->body = mutt_remove_multipart(e_post->body);
decode_descriptions(e_post->body);
mutt_error(_("Error encrypting message. Check your crypt settings."));
return -1;
Expand All @@ -2020,7 +2021,8 @@ static int postpone_message(struct Email *e_post, struct Email *e_cur,
if (mutt_protect(e_post, pgpkeylist, true) == -1)
{
FREE(&pgpkeylist);
e_post->body = mutt_remove_multipart(e_post->body);
if (mutt_istr_equal(e_post->body->subtype, "mixed"))
e_post->body = mutt_remove_multipart(e_post->body);
decode_descriptions(e_post->body);
mutt_error(_("Error encrypting message. Check your crypt settings."));
return -1;
Expand Down Expand Up @@ -2051,7 +2053,8 @@ static int postpone_message(struct Email *e_post, struct Email *e_cur,
}
mutt_env_free(&e_post->body->mime_headers); /* protected headers */
mutt_param_delete(&e_post->body->parameter, "protected-headers");
e_post->body = mutt_remove_multipart(e_post->body);
if (mutt_istr_equal(e_post->body->subtype, "mixed"))
e_post->body = mutt_remove_multipart(e_post->body);
decode_descriptions(e_post->body);
mutt_unprepare_envelope(e_post->env);
return -1;
Expand Down Expand Up @@ -2845,7 +2848,8 @@ int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfi
if ((crypt_get_keys(e_templ, &pgpkeylist, 0) == -1) ||
(mutt_protect(e_templ, pgpkeylist, false) == -1))
{
e_templ->body = mutt_remove_multipart(e_templ->body);
if (mutt_istr_equal(e_templ->body->subtype, "mixed"))
e_templ->body = mutt_remove_multipart(e_templ->body);

FREE(&pgpkeylist);

Expand Down Expand Up @@ -2896,13 +2900,15 @@ int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfi
else if ((e_templ->security & SEC_SIGN) && (e_templ->body->type == TYPE_MULTIPART))
{
mutt_body_free(&e_templ->body->parts->next); /* destroy sig */
e_templ->body = mutt_remove_multipart(e_templ->body);
if (mutt_istr_equal(e_templ->body->subtype, "mixed"))
e_templ->body = mutt_remove_multipart(e_templ->body);
}

FREE(&pgpkeylist);
mutt_env_free(&e_templ->body->mime_headers); /* protected headers */
mutt_param_delete(&e_templ->body->parameter, "protected-headers");
e_templ->body = mutt_remove_multipart(e_templ->body);
if (mutt_istr_equal(e_templ->body->subtype, "mixed"))
e_templ->body = mutt_remove_multipart(e_templ->body);
decode_descriptions(e_templ->body);
mutt_unprepare_envelope(e_templ->env);
FREE(&finalpath);
Expand Down

0 comments on commit 8f895e8

Please sign in to comment.