}
cprintf("+OK Message %d:\r\n", which_one);
- 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);
- msgtext = CC->redirect_buffer;
- CC->redirect_buffer = NULL;
- CC->redirect_len = 0;
- CC->redirect_alloc = 0;
-
- /* If we reach this point, the client is expecting data.
- * Need to parse each line of the message here since someone may have sent
- * a message containing a single dot on a line of its own. In that case we
- * need to escape it in accordance with RFC821.
- * We could do this with the tokenizer functions but num_tokens returns an
- * int and the message may contain more lines than that, also copying each
- * line would be slow.
- */
- nextline = msgtext;
- while (*nextline)
- {
- chunk_to_send = nextline;
- while (*nextline != '\n')
- nextline++;
- nextline++;
- prev_char = *nextline;
- *nextline = '\0';
- if (!strcmp(chunk_to_send, ".\r\n")) {
- client_write("..\r\n", 4);
- }
- else {
- client_write(chunk_to_send, (size_t)(nextline-chunk_to_send));
- }
- *nextline = prev_char;
- }
+ CtdlOutputMsg(POP3->msgs[which_one - 1].msgnum, MT_RFC822, HEADERS_ALL, 0, 1, NULL, ESC_DOT);
cprintf(".\r\n");
}
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, ESC_DOT);
msgtext = CC->redirect_buffer;
msg_size = CC->redirect_len;
CC->redirect_buffer = NULL;
}
}
- /* If we reach this point, the server is expecting data.
- * Need to parse each line of the message here since someone may have sent
- * a message containing a single dot on a line of its own. In that case we
- * need to escape it in accordance with RFC821.
- * We could do this with the tokenizer functions but num_tokens returns an
- * int and the message may contain more lines than that, also copying each
- * line would be slow.
- */
- int bytes_written = 0;
- nextline = msgtext;
- while ( (*nextline) && (bytes_written >= 0) )
- {
- chunk_to_send = nextline;
- while (*nextline != '\n')
- nextline++;
- nextline++;
- prev_char = *nextline;
- *nextline = '\0';
- if (!strcmp(chunk_to_send, ".\r\n")) {
- bytes_written = sock_write(sock, "..\r\n", 4);
- }
- else {
- bytes_written = sock_write(sock, chunk_to_send, (size_t)(nextline-chunk_to_send));
- }
- *nextline = prev_char;
- if (bytes_written < 0) {
- *status = 4;
- strcpy(dsn, "Connection broken during SMTP message transmit");
- goto bail;
- }
- }
-
+ /* If we reach this point, the server is expecting data.*/
+ sock_write(sock, msgtext, msg_size);
if (msgtext[msg_size-1] != 10) {
CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
"correctly terminate. (expecting 0x10, got 0x%02x)\n",
) {
int i, j, k;
char buf[SIZ];
- cit_uint8_t ch;
+ cit_uint8_t ch, prev_ch;
char allkeys[30];
char display_name[256];
char *mptr, *mpptr;
safestrncpy(suser, mptr, sizeof suser);
}
else if (i == 'Y') {
- if (flags & QP_EADDR != 0)
+ if ((flags & QP_EADDR) != 0)
mptr = qp_encode_email_addrs(mptr);
cprintf("CC: %s%s", mptr, nl);
}
cprintf("Return-Path: %s%s", mptr, nl);
}
else if (i == 'V') {
- if (flags & QP_EADDR != 0)
+ if ((flags & QP_EADDR) != 0)
mptr = qp_encode_email_addrs(mptr);
cprintf("Envelope-To: %s%s", mptr, nl);
}
}
else
{
- if (flags & QP_EADDR != 0)
+ if ((flags & QP_EADDR) != 0)
mptr = qp_encode_email_addrs(mptr);
cprintf("To: %s%s", mptr, nl);
}
char outbuf[1024];
int outlen = 0;
int nllen = strlen(nl);
+ prev_ch = 0;
while (ch=*mptr, ch!=0) {
if (ch==13) {
/* do nothing */
}
}
}
+ if (flags & ESC_DOT)
+ {
+ if ((prev_ch == 10) && (ch == '.') && ((*(mptr+1) == 13) || (*(mptr+1) == 10)))
+ {
+ outbuf[outlen++] = '.';
+ }
+ }
+ prev_ch = ch;
++mptr;
if (outlen > 1000) {
client_write(outbuf, outlen);
#define QP_EADDR (1<<0)
#define CRLF (1<<1)
+#define ESC_DOT (1<<2)
+
int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
int mode, /* how would you like that message? */
int headers_only, /* eschew the message body? */