diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-05-28 19:21:28 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-05-28 19:28:59 +0300 |
commit | e863e55881ccfb534cf057e76c95a9ce4a302eab (patch) | |
tree | 7eecc32ad93411c8b3613d459d21321acbdb061c | |
parent | b423246a991eeffe2ed211951cc81db4e03157a2 (diff) | |
download | mailutils-e863e55881ccfb534cf057e76c95a9ce4a302eab.tar.gz mailutils-e863e55881ccfb534cf057e76c95a9ce4a302eab.tar.bz2 |
Amend b8664765e1
The body_end member holds the offset of the first character
that follows the message body. In a well-formed mailbox, it is
the newline character of a blank line that delimits the message.
However, there are mailboxes that lack this blank line. In such
cases body_end points to the ^F of the next envelope line.
When saving the mailbox, delimiting blank lines are always emitted.
* libproto/mbox/mbox.c (mbox_expunge_unlocked): Revert size calculation.
Always emit a blank line after the message.
-rw-r--r-- | libproto/mbox/mbox.c | 7 | ||||
-rw-r--r-- | libproto/mbox/mbox0.h | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c index 768e464b3..0eecfb080 100644 --- a/libproto/mbox/mbox.c +++ b/libproto/mbox/mbox.c @@ -1102,7 +1102,7 @@ append_message_to_stream (mu_stream_t ostr, mu_message_t msg, status = mu_stream_copy (ostr, flt, 0, NULL); mu_stream_destroy (&flt); if (status == 0) - status = mu_stream_write (ostr, "\n", 1, NULL); + status = mu_stream_write (ostr, "\n", 1, NULL); } return status; @@ -1269,7 +1269,10 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted, return status; } status = mu_stream_copy (tempstr, mailbox->stream, - mum->body_end - mum->envel_from + 1, NULL); + mum->body_end - mum->envel_from, NULL); + /* Terminate messate with an empty line */ + if (status == 0) + status = mu_stream_write (tempstr, "\n", 1, NULL); if (status) { mu_error (_("%s:%d: error copying: %s"), diff --git a/libproto/mbox/mbox0.h b/libproto/mbox/mbox0.h index 4e9cb90af..16ca7c21e 100644 --- a/libproto/mbox/mbox0.h +++ b/libproto/mbox/mbox0.h @@ -73,7 +73,12 @@ struct _mbox_message mu_off_t envel_from; /* Start of envelope (^From ) */ mu_off_t envel_from_end; /* End of envelope (terminating \n) */ mu_off_t body; /* Start of body */ - mu_off_t body_end; /* End of body */ + mu_off_t body_end; /* End of body. This is the first character + past the body. Normally, it is the newline + character of the blank line that follows the + message. If such a line is missing, it is + the offset of the next envelope ^F (or size + of mailbox if it is the last message). */ size_t header_lines; /* Number of lines in header */ size_t body_lines; /* Number of lines in message body */ |