When one is missing, include the previous newline as part of the
message.

This addresses ticket 415.  It's not a perfect solution, but it stops
the problem from propagating into other mbox files.
---
 mbox.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mbox.c b/mbox.c
index a2a32d13..2a266da7 100644
--- a/mbox.c
+++ b/mbox.c
@@ -314,7 +314,8 @@ int mbox_parse_mailbox (CONTEXT *ctx)
 
        if (PREV->content->length < 0)
        {
-         PREV->content->length = loc - PREV->content->offset - 1;
+         PREV->content->length = loc - PREV->content->offset -
+                                  (has_mbox_sep ? 1 : 0);
          if (PREV->content->length < 0)
            PREV->content->length = 0;
        }
@@ -451,7 +452,8 @@ int mbox_parse_mailbox (CONTEXT *ctx)
 
     if (PREV->content->length < 0)
     {
-      PREV->content->length = ftello (ctx->fp) - PREV->content->offset - 1;
+      PREV->content->length = ftello (ctx->fp) - PREV->content->offset -
+                              (has_mbox_sep ? 1 : 0);
       if (PREV->content->length < 0)
        PREV->content->length = 0;
     }
-- 
2.52.0

Reply via email to