Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6339:301d0f8e4f91 HEAD
Fixes to saving mails
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 01 Sep 2007 01:36:10 +0300 |
parents | bfb6aeddef9b |
children | 7b71ba1250e3 |
files | src/lib-storage/index/mbox/mbox-save.c |
diffstat | 1 files changed, 17 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c Sat Sep 01 00:36:00 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Sat Sep 01 01:36:10 2007 +0300 @@ -47,7 +47,7 @@ struct istream *input; struct ostream *output, *body_output; - uoff_t extra_hdr_offset, eoh_offset, eoh_input_offset; + uoff_t extra_hdr_offset, eoh_offset; char last_char; struct mbox_md5_context *mbox_md5_ctx; @@ -344,10 +344,6 @@ if (!*matched && ctx->mbox_md5_ctx != NULL) mbox_md5_continue(ctx->mbox_md5_ctx, hdr); } - - if ((hdr == NULL && ctx->eoh_input_offset == (uoff_t)-1) || - (hdr != NULL && hdr->eoh)) - ctx->eoh_input_offset = ctx->input->v_offset; } static void mbox_save_x_delivery_id(struct mbox_save_context *ctx) @@ -462,7 +458,6 @@ i_assert(mbox->mbox_lock_type == F_WRLCK); ctx->mail_offset = ctx->output->offset; - ctx->eoh_input_offset = (uoff_t)-1; ctx->eoh_offset = (uoff_t)-1; ctx->last_char = '\n'; ctx->received_date = received_date; @@ -497,7 +492,7 @@ { struct mbox_save_context *ctx = (struct mbox_save_context *)_ctx; const unsigned char *data; - size_t size; + size_t i, size; ssize_t ret; if (ctx->failed) @@ -539,15 +534,22 @@ return 0; data = i_stream_get_data(ctx->input, &size); - if (ctx->eoh_input_offset != (uoff_t)-1 && - ctx->input->v_offset + size >= ctx->eoh_input_offset) { - /* found end of headers. write the rest of them. */ - size = ctx->eoh_input_offset - ctx->input->v_offset; - if (o_stream_send(ctx->output, data, size) < 0) + for (i = 0; i < size; i++) { + if (data[i] == '\n' && + ((i == 0 && ctx->last_char == '\n') || + (i > 0 && data[i-1] == '\n'))) { + /* end of headers. we don't need to worry about + CRs because they're dropped */ + break; + } + } + if (i != size) { + /* found end of headers. write the rest of them + (not including the finishing empty line) */ + if (o_stream_send(ctx->output, data, i) < 0) return write_error(ctx); - if (size > 0) - ctx->last_char = data[size-1]; - i_stream_skip(ctx->input, size + 1); + ctx->last_char = '\n'; + i_stream_skip(ctx->input, i + 1); break; }