Write out the protected headers when writing the mime header part.
Hide protected subjects with $crypt_protected_headers_subject, for
outgoing, postponed, and fcc'ed messages.
Don't hide in postponed and fcc'ed if $crypt_protected_headers_read
isn't set.
Add a few missing cases where mime_headers needed to be cleaned up on
error.
Remove the protected headers for $fcc_clear.
Co-authored-by: Richard Russon <rich@flatcap.org>
mutt_env_to_intl(msg->env, NULL, NULL);
}
- mutt_rfc822_write_header(fout, msg->env, msg->content,
- MUTT_WRITE_HEADER_POSTPONE, false);
+ mutt_rfc822_write_header(
+ fout, msg->env, msg->content, MUTT_WRITE_HEADER_POSTPONE, false,
+ CryptProtectedHeadersRead && mutt_should_hide_protected_subject(msg));
if (ResumeEditedDraftFiles)
fprintf(fout, "X-Mutt-Resume-Draft: 1\n");
fputc('\n', fout);
}
mutt_env_to_local(msg->env);
- mutt_rfc822_write_header(ofp, msg->env, NULL, MUTT_WRITE_HEADER_EDITHDRS, false);
+ mutt_rfc822_write_header(ofp, msg->env, NULL, MUTT_WRITE_HEADER_EDITHDRS, false, false);
fputc('\n', ofp); /* tie off the header. */
/* now copy the body of the message. */
}
}
+bool mutt_should_hide_protected_subject(struct Email *e)
+{
+ if (CryptProtectedHeadersWrite && (e->security & ENCRYPT) && !(e->security & INLINE) &&
+ CryptProtectedHeadersSubject && *CryptProtectedHeadersSubject)
+ {
+ return true;
+ }
+
+ return false;
+}
+
/**
* mutt_protected_headers_handler - Process a protected header - Implements ::handler_t
*/
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b);
int mutt_protect(struct Email *msg, char *keylist);
int mutt_protected_headers_handler(struct Body *m, struct State *s);
+bool mutt_should_hide_protected_subject(struct Email *e);
int mutt_signed_handler(struct Body *a, struct State *s);
/* cryptglue.c */
#endif
#ifdef MIXMASTER
mutt_rfc822_write_header(tempfp, msg->env, msg->content,
- MUTT_WRITE_HEADER_NORMAL, !STAILQ_EMPTY(&msg->chain));
+ MUTT_WRITE_HEADER_NORMAL, !STAILQ_EMPTY(&msg->chain),
+ mutt_should_hide_protected_subject(msg));
#endif
#ifndef MIXMASTER
- mutt_rfc822_write_header(tempfp, msg->env, msg->content, MUTT_WRITE_HEADER_NORMAL, false);
+ mutt_rfc822_write_header(tempfp, msg->env, msg->content, MUTT_WRITE_HEADER_NORMAL,
+ false, mutt_should_hide_protected_subject(msg));
#endif
#ifdef USE_SMTP
if (old_write_bcc)
struct Body *save_parts = NULL;
if ((WithCrypto != 0) && (msg->security & (ENCRYPT | SIGN)) && FccClear)
+ {
msg->content = clear_content;
+ msg->security &= ~(ENCRYPT | SIGN);
+ mutt_env_free(&msg->content->mime_headers);
+ }
/* check to see if the user wants copies of all attachments */
if (msg->content->type == TYPE_MULTIPART)
mutt_body_free(&msg->content);
msg->content = clear_content;
}
+ mutt_env_free(&msg->content->mime_headers); /* protected headers */
msg->content = mutt_remove_multipart(msg->content);
decode_descriptions(msg->content);
mutt_unprepare_envelope(msg->env);
msg->content = mutt_remove_multipart(msg->content);
}
+ mutt_env_free(&msg->content->mime_headers); /* protected headers */
msg->content = mutt_remove_multipart(msg->content);
decode_descriptions(msg->content);
mutt_unprepare_envelope(msg->env);
#endif
}
- if ((WithCrypto != 0) && (msg->security & ENCRYPT))
+ if (WithCrypto)
FREE(&pgpkeylist);
if ((WithCrypto != 0) && free_clear_content)
if (a->encoding != ENC_7BIT)
fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING(a->encoding));
+ if (CryptProtectedHeadersWrite && a->mime_headers)
+ mutt_rfc822_write_header(f, a->mime_headers, NULL, MUTT_WRITE_HEADER_MIME, false, false);
+
/* Do NOT add the terminator here!!! */
return ferror(f) ? -1 : 0;
}
* privacy true => will omit any headers which may identify the user.
* Output generated is suitable for being sent through
* anonymous remailer chains.
+ *
+ * hide_protected_subject: replaces the Subject header with
+ * $crypt_protected_headers_subject in NORMAL or POSTPONE mode.
*/
-int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach,
- enum MuttWriteHeaderMode mode, bool privacy)
+int mutt_rfc822_write_header(FILE *fp, struct Envelope *env,
+ struct Body *attach, enum MuttWriteHeaderMode mode,
+ bool privacy, bool hide_protected_subject)
{
char buf[LONG_STRING];
char *p = NULL, *q = NULL;
#endif
if (env->subject)
- mutt_write_one_header(fp, "Subject", env->subject, NULL, 0, 0);
+ {
+ if (hide_protected_subject &&
+ (mode == MUTT_WRITE_HEADER_NORMAL || mode == MUTT_WRITE_HEADER_POSTPONE))
+ mutt_write_one_header(fp, "Subject", CryptProtectedHeadersSubject, NULL, 0, 0);
+ else
+ mutt_write_one_header(fp, "Subject", env->subject, NULL, 0, 0);
+ }
else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
fputs("Subject:\n", fp);
/* post == 1 => postpone message.
* post == 0 => Normal mode.
*/
- mutt_rfc822_write_header(msg->fp, e->env, e->content,
- post ? MUTT_WRITE_HEADER_POSTPONE : MUTT_WRITE_HEADER_NORMAL,
- false);
+ mutt_rfc822_write_header(
+ msg->fp, e->env, e->content, post ? MUTT_WRITE_HEADER_POSTPONE : MUTT_WRITE_HEADER_NORMAL,
+ false, CryptProtectedHeadersRead && mutt_should_hide_protected_subject(e));
/* (postponement) if this was a reply of some sort, <msgid> contains the
* Message-ID: of message replied to. Save it using a special X-Mutt-
void mutt_prepare_envelope(struct Envelope *env, bool final);
struct Address *mutt_addrlist_dedupe(struct Address *addr);
struct Body * mutt_remove_multipart(struct Body *b);
-int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach, enum MuttWriteHeaderMode mode, bool privacy);
+int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach, enum MuttWriteHeaderMode mode, bool privacy, bool hide_protected_subject);
void mutt_stamp_attachment(struct Body *a);
void mutt_unprepare_envelope(struct Envelope *env);
void mutt_update_encoding(struct Body *a);