0.9.8claws5
authorLuke Plant <L.Plant.98@cantab.net>
Sat, 20 Dec 2003 16:27:32 +0000 (16:27 +0000)
committerLuke Plant <L.Plant.98@cantab.net>
Sat, 20 Dec 2003 16:27:32 +0000 (16:27 +0000)
        fix unfolding/newline stripping for multiline fields
        in generic_get_one_field()

src/procheader.c

index b80f10e..1514964 100644 (file)
@@ -139,33 +139,31 @@ static gint generic_get_one_field(gchar *buf, gint len, void *data,
                if (buf[0] == '\r' || buf[0] == '\n') return -1;
        }
 
-       /* remove trailing new line */
-       strretchomp(buf);
-
-#define UNFOLD_LINE() \
-       (!hentry || (hp && hp->unfold))
-
        /* unfold line */
        while (1) {
                nexthead = peekchar(data);
                /* ([*WSP CRLF] 1*WSP) */
                if (nexthead == ' ' || nexthead == '\t') {
-                       size_t buflen = strlen(buf);
+                       size_t buflen;
+                       /* trim previous trailing \n if requesting one header or
+                        * unfolding was requested */
+                       if (!hentry || (hp && hp->unfold))
+                               strretchomp(buf);
+
+                       buflen = strlen(buf);
                        
                        /* concatenate next line */
                        if ((len - buflen) > 2) {
                                if (getline(buf + buflen, len - buflen, data) == NULL)
                                        break;
-                               /* trim trailing \n if requesting one header or
-                                * unfolding was requested */
-                               if (UNFOLD_LINE())                               
-                                   strretchomp(buf);
                        } else
                                break;
-               } else
+               } else {
+                       /* remove trailing new line */
+                       strretchomp(buf);
                        break;
+               }
        }
-#undef UNFOLD_LINE     
 
        return hnum;
 }