mx.c |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

# HG changeset patch
# User David Champion <[email protected]>
# Date 1472604902 25200
#      Tue Aug 30 17:55:02 2016 -0700
# Node ID d0273005656c26a0339146b22e7cd9acf52faa0a
# Parent  ed54319fbefaeba45479402175830f5d06ec93b0
allow initial blank lines in local mailboxes

Some mailbox-creation tools erroneously append a blank line to a file
before appending a UNIXv7-format mail message, resulting in mailboxes
that are intended to me valid "mbox" folders but are not.  Notably old
versions of Mailman do this, making archive files that cannot be read by
mutt.

This patch causes mutt to skip leading NLs and CRs when detecting magic.

diff --git a/mx.c b/mx.c
--- a/mx.c
+++ b/mx.c
@@ -415,6 +415,11 @@
   else if ((f = fopen (path, "r")) != NULL)
   {
     struct utimbuf times;
+    int ch = 0;
+
+    while ((ch = fgetc(f)) && (ch == '\n' || ch == '\r'));
+    if (!feof(f) && ch)
+      ungetc(ch, f);
 
     fgets (tmp, sizeof (tmp), f);
     if (mutt_strncmp ("From ", tmp, 5) == 0)

Reply via email to