Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4412:521d07f9c247 HEAD
If saved mail's body doesn't end with LF, add it ourself.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 17 Jun 2006 21:00:35 +0300 |
parents | a2420b745cd5 |
children | 96d9947fde60 |
files | src/lib-storage/index/mbox/mbox-save.c |
diffstat | 1 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c Sat Jun 17 20:19:29 2006 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Sat Jun 17 21:00:35 2006 +0300 @@ -456,9 +456,28 @@ if (ctx->eoh_offset != (uoff_t)-1) { /* writing body */ - if (o_stream_send_istream(ctx->body_output, ctx->input) < 0) { - write_error(ctx, ctx->body_output->stream_errno); - return -1; + while ((ret = i_stream_read(ctx->input)) != -1) { + if (ret == 0) + return 0; + + data = i_stream_get_data(ctx->input, &size); + if (o_stream_send(ctx->output, data, size) < 0) { + write_error(ctx, ctx->output->stream_errno); + return -1; + } + ctx->last_char = data[size-1]; + i_stream_skip(ctx->input, size); + } + + if (ctx->last_char != '\n') { + /* if mail doesn't end with LF, we'll do that. + otherwise some mbox parsers don't like the result. + this makes it impossible to save a mail that doesn't + end with LF though. */ + if (o_stream_send(ctx->output, "\n", 1) < 0) { + write_error(ctx, ctx->output->stream_errno); + return -1; + } } return 0; }