[balsa] Try to recover from parser failure
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Try to recover from parser failure
- Date: Thu, 4 May 2017 14:22:28 +0000 (UTC)
commit 9df15e65e086d94c236402050255152e4ce1e2f3
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu May 4 10:21:44 2017 -0400
Try to recover from parser failure
* libbalsa/mailbox_mbox.c (parse_mailbox): try to recover when
the GMimeParser returns a NULL GMimeMessage.
ChangeLog | 5 +++++
libbalsa/mailbox_mbox.c | 19 ++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f4ebf84..04718aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2017-05-04 Peter Bloomfield <pbloomfield bellsouth net>
+ * libbalsa/mailbox_mbox.c (parse_mailbox): try to recover when
+ the GMimeParser returns a NULL GMimeMessage.
+
+2017-05-04 Peter Bloomfield <pbloomfield bellsouth net>
+
* libbalsa/mailbox_pop3.c (message_cb): reset the GMimeStream
before passing it to libbalsa_mailbox_add_message.
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index ac4cd3f..ff5ecbb 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -487,8 +487,25 @@ parse_mailbox(LibBalsaMailboxMbox * mbox)
msg_info.status = msg_info.x_status = msg_info.mime_version = -1;
mime_message = g_mime_parser_construct_message(gmime_parser);
- if (!mime_message)
+ if (mime_message == NULL) {
+ /* Skip to the next message, if any */
+ GMimeStream *mbox_stream;
+
+ mbox_stream = mbox->gmime_stream;
+ while (!g_mime_stream_eos(mbox_stream)) {
+ gchar c;
+
+ while (g_mime_stream_read(mbox_stream, &c, 1) == 1)
+ if (c == '\n')
+ break;
+
+ if (lbm_mbox_stream_seek_to_message(mbox_stream,
+ g_mime_stream_tell(mbox_stream)))
+ break;
+ }
+ g_mime_parser_init_with_stream(gmime_parser, mbox_stream);
continue;
+ }
msg_info.start = g_mime_parser_get_from_offset(gmime_parser);
msg_info.end = g_mime_parser_tell(gmime_parser);
if (msg_info.end <= msg_info.start
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]