changeset 9516:a1622da31bb1 HEAD

message-header-parsed: Backported fixes from v2.0.
author Timo Sirainen <tss@iki.fi>
date Tue, 22 Dec 2009 14:02:10 -0500
parents b934756a3714
children 4e2134570b76
files src/lib-mail/message-header-parser.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/message-header-parser.c	Thu Dec 17 14:00:30 2009 -0500
+++ b/src/lib-mail/message-header-parser.c	Tue Dec 22 14:02:10 2009 -0500
@@ -107,7 +107,7 @@
 				return -1;
 			}
 
-			if (size > 0 &&
+			if (size > 0 && !ctx->skip_line &&
 			    (msg[0] == '\n' ||
 			     (msg[0] == '\r' && size > 1 && msg[1] == '\n'))) {
 				/* end of headers - this mostly happens just
@@ -136,6 +136,7 @@
 			   b) header ended unexpectedly */
 			if (colon_pos == UINT_MAX && ret == -2 && !continued) {
 				/* header name is huge. just skip it. */
+				i_assert(size > 1);
 				if (msg[size-1] == '\r')
 					size--;
 
@@ -172,7 +173,7 @@
 				if (msg[i] > ':')
 					continue;
 
-				if (msg[i] == ':') {
+				if (msg[i] == ':' && !ctx->skip_line) {
 					colon_pos = i;
 					line->full_value_offset =
 						ctx->input->v_offset + i + 1;
@@ -203,20 +204,19 @@
 		if (i < parse_size) {
 			/* got a line */
 			if (ctx->skip_line) {
-				/* skipping a huge line */
+				/* skipping a line with a huge header name */
 				if (ctx->hdr_size != NULL) {
-					ctx->hdr_size->physical_size += i;
-					ctx->hdr_size->virtual_size += i;
+					ctx->hdr_size->lines++;
+					ctx->hdr_size->physical_size += i + 1;
+					ctx->hdr_size->virtual_size += i + 1;
 				}
-
 				if (i == 0 || msg[i-1] != '\r') {
 					/* missing CR */
 					if (ctx->hdr_size != NULL)
 						ctx->hdr_size->virtual_size++;
-				} else {
-					crlf_newline = TRUE;
 				}
-				i_stream_skip(ctx->input, i);
+
+				i_stream_skip(ctx->input, i + 1);
 				startpos = 0;
 				ctx->skip_line = FALSE;
 				continue;
@@ -355,7 +355,6 @@
 		}
 		line->full_value = buffer_get_data(ctx->value_buf,
 						   &line->full_value_len);
-		line->value = line->full_value + value_pos;
 	} else {
 		/* we didn't want full_value, and this is a continued line. */
 		line->full_value = NULL;