Corrected handling of long header fields in compliance to section
authorJoey Schulze <joey@infodrom.org>
Tue, 7 Feb 2006 18:27:06 +0000 (18:27 +0000)
committerJoey Schulze <joey@infodrom.org>
Tue, 7 Feb 2006 18:27:06 +0000 (18:27 +0000)
2.2.3 of RFC 2822

mbox.c

diff --git a/mbox.c b/mbox.c
index 6385b92..0fc2491 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -37,6 +37,7 @@ struct mail {
 
 #define HDR_LEN        128
 #define TAB    0x09
+#define LWSP   0x20
 
 /*
  * Like strncpy() but with terminated result.
@@ -182,7 +183,9 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
 
       if (inheader && !feof(f)) {
        lookahead = fgetc(f);
-       if (lookahead == TAB) {
+       if (lookahead == TAB || lookahead == LWSP) {
+         if (buf[strlen(buf)-1] != LWSP)
+           strncat (buf, " ", sizeof(buf)-strlen(buf)-1);
          if ((cp = fgets(tmp, sizeof(tmp), f)) != NULL) {
            strncat (buf, tmp, sizeof(buf)-strlen(buf)-1);
            if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')