dovecot-1.1: message_header_decode*() should ignore LWSP between...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 14 02:01:47 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.1/rev/9c241c8b2700
changeset: 8351:9c241c8b2700
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 13 19:01:28 2009 -0400
description:
message_header_decode*() should ignore LWSP between two encoded-words.

diffstat:

1 file changed, 14 insertions(+), 1 deletion(-)
src/lib-mail/message-header-decode.c |   15 ++++++++++++++-

diffs (32 lines):

diff -r d51e3de292ad -r 9c241c8b2700 src/lib-mail/message-header-decode.c
--- a/src/lib-mail/message-header-decode.c	Thu Sep 10 19:13:19 2009 -0400
+++ b/src/lib-mail/message-header-decode.c	Sun Sep 13 19:01:28 2009 -0400
@@ -56,6 +56,18 @@ message_header_decode_encoded(const unsi
 	return start_pos[2] + 2;
 }
 
+static bool is_only_lwsp(const unsigned char *data, unsigned int size)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; i++) {
+		if (!(data[i] == ' ' || data[i] == '\t' ||
+		      data[i] == '\r' || data[i] == '\n'))
+			return FALSE;
+	}
+	return TRUE;
+}
+
 void message_header_decode(const unsigned char *data, size_t size,
 			   message_header_decode_callback_t *callback,
 			   void *context)
@@ -73,7 +85,8 @@ void message_header_decode(const unsigne
 		}
 
 		/* encoded string beginning */
-		if (pos != start_pos) {
+		if (pos != start_pos &&
+		    !is_only_lwsp(data+start_pos, pos-start_pos)) {
 			/* send the unencoded data so far */
 			if (!callback(data + start_pos, pos - start_pos,
 				      NULL, context)) {


More information about the dovecot-cvs mailing list