# HG changeset patch # User Timo Sirainen # Date 1032776557 -10800 # Node ID e6a00377af97ed7935f19babc5008bca708d791d # Parent 21d53f6b38fcb3a5871b5c27cc32b932a54bbe47 Better checking for the ending From-line, so it won't falsely check it in some outbox messages. diff -r 21d53f6b38fc -r e6a00377af97 src/lib-index/mbox/mbox-index.c --- 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; + } } } }