summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-25 15:49:58 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-25 15:49:58 +0200
commit1bcece404bf0ec7a2d2941511350e8f2a6f65736 (patch)
tree1821352c6135bd72ca2cb23e21367f116a39291a
parenta3bd653315227a7cfb0a855acfa5bbe13c8f2645 (diff)
downloadmailutils-1bcece404bf0ec7a2d2941511350e8f2a6f65736.tar.gz
mailutils-1bcece404bf0ec7a2d2941511350e8f2a6f65736.tar.bz2
Improve mboxrb scanner
* libproto/mbox/mboxrb.c: Request that the From_line be preceded by an empty line.
-rw-r--r--libproto/mbox/mboxrb.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libproto/mbox/mboxrb.c b/libproto/mbox/mboxrb.c
index 7c55e7d59..412f58f61 100644
--- a/libproto/mbox/mboxrb.c
+++ b/libproto/mbox/mboxrb.c
@@ -519,9 +519,10 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
size_t n;
enum mboxrb_scan_state
{
- mboxrb_scan_init,
- mboxrb_scan_header,
- mboxrb_scan_body
+ mboxrb_scan_init, /* At the beginning of the file */
+ mboxrb_scan_header,/* Scanning message header */
+ mboxrb_scan_body, /* Scanning message body */
+ mboxrb_scan_empty_line /* At the empty line within or at the end of body */
} state = mboxrb_scan_init;
struct mu_mboxrb_message *dmsg = NULL;
char *zn, *ti;
@@ -664,6 +665,13 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
break;
case mboxrb_scan_body:
+ if (n == 1 && buf[0] == '\n')
+ {
+ state = mboxrb_scan_empty_line;
+ }
+ break;
+
+ case mboxrb_scan_empty_line:
if ((ti = parse_from_line (buf, &zn)) != 0)
{
/* Finalize current message */
@@ -717,6 +725,10 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
dmsg->env_sender_len -= 5;
state = mboxrb_scan_header;
}
+ else if (n == 1 && buf[0] == '\n')
+ state = mboxrb_scan_empty_line;
+ else
+ state = mboxrb_scan_body;
}
if (++numlines % 1000 == 0)
mboxrb_dispatch (mailbox, MU_EVT_MAILBOX_PROGRESS, NULL);

Return to:

Send suggestions and report system problems to the System administrator.