CC->redirect_alloc = SIZ;
CtdlOutputMsg(msgnum, MT_RFC822,
(need_body ? HEADERS_ALL : HEADERS_FAST),
- 0, 1, NULL, 0);
+ 0, 1, NULL, SUPPRESS_ENV_TO
+ );
if (!need_body) cprintf("\r\n"); /* extra trailing newline */
IMAP->cached_rfc822_data = CC->redirect_buffer;
IMAP->cached_rfc822_len = CC->redirect_len;
}
else if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, SUPPRESS_ENV_TO);
}
else if (!strcmp(section, "")) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, SUPPRESS_ENV_TO);
}
/*
* IMAP library and this broke Mail.App and iPhone Mail, so we had to change it
* to HEADERS_ONLY so the trendy hipsters with their iPhones can read mail.
*/
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1, SUPPRESS_ENV_TO);
imap_strip_headers(section);
}
* Strip it down if the client asked for everything _except_ headers.
*/
else if (!strncasecmp(section, "TEXT", 4)) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, SUPPRESS_ENV_TO);
}
/*
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1, SUPPRESS_ENV_TO);
rfc822 = CC->redirect_buffer;
rfc822_len = CC->redirect_len;
CC->redirect_buffer = NULL;
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0);
+ CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, SUPPRESS_ENV_TO);
smi.meta_rfc822_length = CC->redirect_len;
free(CC->redirect_buffer);
CC->redirect_buffer = NULL;
}
cprintf("+OK Message %d:\r\n", which_one);
- CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, ESC_DOT);
+ CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum,
+ MT_RFC822, HEADERS_ALL, 0, 1, NULL,
+ (ESC_DOT|SUPPRESS_ENV_TO)
+ );
cprintf(".\r\n");
}
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum,
- MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0);
+ CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, SUPPRESS_ENV_TO);
msgtext = CC->redirect_buffer;
CC->redirect_buffer = NULL;
CC->redirect_len = 0;
int do_proto, /* do Citadel protocol responses? */
int crlf, /* Use CRLF newlines instead of LF? */
char *section, /* NULL or a message/rfc822 section */
- int flags /* should the bessage be exported clean? */
+ int flags /* various flags; see msgbase.h */
) {
struct CtdlMessage *TheMessage = NULL;
int retcode = om_no_such_msg;
return(om_no_such_msg);
}
+ /* Suppress envelope recipients if required to avoid disclosing BCC addresses.
+ * Pad it with spaces in order to avoid changing the RFC822 length of the message.
+ */
+ if ( (flags & SUPPRESS_ENV_TO) && (TheMessage->cm_fields['V'] != NULL) ) {
+ memset(TheMessage->cm_fields['V'], ' ', strlen(TheMessage->cm_fields['V']));
+ }
+
/* Are we downloading a MIME component? */
if (mode == MT_DOWNLOAD) {
if (TheMessage->cm_format_type != FMT_RFC822) {
if (haschar(TheMessage->cm_fields['N'], '.') == 0) {
suppress_f = 1;
}
-
+
/* Now spew the header fields in the order we like them. */
safestrncpy(allkeys, FORDER, sizeof allkeys);
for (i=0; i<strlen(allkeys); ++i) {
int flags /* should the bessage be exported clean? */
);
-#define QP_EADDR (1<<0)
-#define CRLF (1<<1)
-#define ESC_DOT (1<<2)
+/* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
+#define QP_EADDR (1<<0) /* quoted-printable encode email addresses */
+#define CRLF (1<<1)
+#define ESC_DOT (1<<2) /* output a line containing only "." as ".." instead */
+#define SUPPRESS_ENV_TO (1<<3) /* suppress Envelope-to: header (warning: destructive!) */
int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
int mode, /* how would you like that message? */