summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2017-08-10 18:18:28 -0700
committerKevin McCarthy <kevin@8t8.us>2017-08-10 18:18:28 -0700
commitfaabd6210348dd5ae8b3dc5f788ad694b342f714 (patch)
tree7c8a06f8a12e922d2fd8e9a38b33a57511cc0aa7 /commands.c
parent050125068504624fa7e70972df8f8e35122349eb (diff)
Add edit-content-type helper and warning for decrypted attachments. (closes #3728)
Regenerating the actx index will overwrite any changes made to a decrypted attachment. Change the mutt_edit_content_type() function to return 1 when a structural change is made. Add a warning message when that is the case and a decrypted message was edited, so the user is not surprised. Note: mutt_edit_content_type() appeared to regenerate multipart subparts every time, leading to a memory leak. I believe this was an oversite, and it should have regenerated only when there were no subparts, so have "fixed" this.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/commands.c b/commands.c
index 2cfa9add..d1bf5d53 100644
--- a/commands.c
+++ b/commands.c
@@ -878,7 +878,13 @@ void mutt_version (void)
mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
}
-void mutt_edit_content_type (HEADER *h, 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 (HEADER *h, BODY *b, FILE *fp)
{
char buf[LONG_STRING];
char obuf[LONG_STRING];
@@ -890,6 +896,7 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
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));
@@ -911,7 +918,7 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
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);
@@ -952,15 +959,22 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
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)
{
@@ -969,6 +983,8 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
h->security |= crypt_query (b);
}
+
+ return structure_changed;
}