changeset 9096:eead0542095f HEAD

message header parser: Don't set hdr->continues=TRUE when hdr->eoh=TRUE. This happened if body began with LWSP. Also if parser has seen eoh but not the following character, don't bother waiting for it.
author Timo Sirainen <tss@iki.fi>
date Tue, 26 May 2009 16:53:29 -0400
parents 9a0aa39a3a14
children 77aab257cea2
files src/lib-mail/message-header-parser.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/message-header-parser.c	Tue May 26 14:21:59 2009 -0400
+++ b/src/lib-mail/message-header-parser.c	Tue May 26 16:53:29 2009 -0400
@@ -106,14 +106,10 @@
 				/* error / EOF with no bytes */
 				return -1;
 			}
-			if (ret == 0 && !ctx->input->eof) {
-				/* stream is nonblocking - need more data */
-				return 0;
-			}
-			i_assert(size > 0);
 
-			if (msg[0] == '\n' ||
-			    (msg[0] == '\r' && size > 1 && msg[1] == '\n')) {
+			if (size > 0 &&
+			    (msg[0] == '\n' ||
+			     (msg[0] == '\r' && size > 1 && msg[1] == '\n'))) {
 				/* end of headers - this mostly happens just
 				   with mbox where headers are read separately
 				   from body */
@@ -130,6 +126,11 @@
 				}
 				break;
 			}
+			if (ret == 0 && !ctx->input->eof) {
+				/* stream is nonblocking - need more data */
+				return 0;
+			}
+			i_assert(size > 0);
 
 			/* a) line is larger than input buffer
 			   b) header ended unexpectedly */
@@ -256,6 +257,8 @@
 		line->name_len = line->value_len = line->full_value_len = 0;
 		line->name = ""; line->value = line->full_value = NULL;
 		line->middle = NULL; line->middle_len = 0;
+		line->full_value_offset = line->name_offset;
+		line->continues = FALSE;
 	} else if (line->continued) {
 		line->value = msg;
 		line->value_len = size;