Mercurial > dovecot > original-hg > dovecot-1.2
changeset 294:e6a00377af97 HEAD
Better checking for the ending From-line, so it won't falsely check it in
some outbox messages.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 23 Sep 2002 13:22:37 +0300 |
parents | 21d53f6b38fc |
children | c6c0e376008f |
files | src/lib-index/mbox/mbox-index.c |
diffstat | 1 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-index.c Mon Sep 23 12:18:58 2002 +0300 +++ b/src/lib-index/mbox/mbox-index.c Mon Sep 23 13:22:37 2002 +0300 @@ -314,6 +314,25 @@ } } +static int mbox_is_valid_from(IOBuffer *inbuf, size_t startpos) +{ + unsigned char *msg; + size_t i, size; + + i = startpos; + while (io_buffer_read_data_blocking(inbuf, &msg, &size, i) > 0) { + for (; i < size; i++) { + if (msg[i] == '\n') { + msg += startpos; + i -= startpos; + return mbox_from_parse_date(msg, size) != 0; + } + } + } + + return FALSE; +} + void mbox_skip_message(IOBuffer *inbuf) { unsigned char *msg; @@ -329,11 +348,17 @@ if (msg[i-5] == '\n' && msg[i-4] == 'F' && msg[i-3] == 'r' && msg[i-2] == 'o' && msg[i-1] == 'm') { - /* yes, see if we had \r too */ - i -= 5; - if (i > 0 && msg[i-1] == '\r') - i--; - break; + /* check still that the From-line looks + actually valid, in outbox there + might be some lines beginning with + From. */ + if (mbox_is_valid_from(inbuf, i-4)) { + /* see if we had \r too */ + i -= 5; + if (i > 0 && msg[i-1] == '\r') + i--; + break; + } } } }