changeset 14605:6846c2e50eba

message parser: Added MESSAGE_PARSER_FLAG_INCLUDE_BOUNDARIES flag.
author Timo Sirainen <tss@iki.fi>
date Wed, 20 Jun 2012 02:22:27 +0300
parents 217fe26a3176
children 7b1378fe8820
files src/lib-mail/message-parser.c src/lib-mail/message-parser.h
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c	Wed Jun 20 02:21:54 2012 +0300
+++ b/src/lib-mail/message-parser.c	Wed Jun 20 02:22:27 2012 +0300
@@ -269,7 +269,10 @@
 	ptr = memchr(block_r->data, '\n', block_r->size);
 	if (ptr == NULL) {
 		parse_body_add_block(ctx, block_r);
-		return 1;
+		if (block_r->size > 0 &&
+		    (ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_BOUNDARIES) != 0)
+			return 1;
+		return 0;
 	}
 
 	/* found the LF */
@@ -286,6 +289,9 @@
 		/* a new MIME part begins */
 		ctx->parse_next_block = parse_next_mime_header_init;
 	}
+	if (block_r->size > 0 &&
+	    (ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_BOUNDARIES) != 0)
+		return 1;
 	return ctx->parse_next_block(ctx, block_r);
 }
 
@@ -333,6 +339,8 @@
 
 	ctx->parse_next_block = parse_next_body_skip_boundary_line;
 
+	if ((ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_BOUNDARIES) != 0)
+		return 1;
 	return ctx->parse_next_block(ctx, block_r);
 }
 
--- a/src/lib-mail/message-parser.h	Wed Jun 20 02:21:54 2012 +0300
+++ b/src/lib-mail/message-parser.h	Wed Jun 20 02:22:27 2012 +0300
@@ -6,13 +6,15 @@
 
 enum message_parser_flags {
 	/* Don't return message bodies in message_blocks. */
-	MESSAGE_PARSER_FLAG_SKIP_BODY_BLOCK	= 0x01,
+	MESSAGE_PARSER_FLAG_SKIP_BODY_BLOCK		= 0x01,
 	/* Buggy software creates Content-Type: headers without Mime-Version:
 	   header. By default we allow this and assume message is MIME if
 	   Content-Type: is found. This flag disables this. */
-	MESSAGE_PARSER_FLAG_MIME_VERSION_STRICT	= 0x02,
+	MESSAGE_PARSER_FLAG_MIME_VERSION_STRICT		= 0x02,
 	/* Return multipart (preamble and epilogue) blocks */
-	MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS = 0x04
+	MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS	= 0x04,
+	/* Return --boundary lines */
+	MESSAGE_PARSER_FLAG_INCLUDE_BOUNDARIES		= 0x08
 };
 
 /* Note that these flags are used directly by message-parser-serialize, so