[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c, 1.46, 1.47

cras at dovecot.org cras at dovecot.org
Fri Oct 28 17:32:04 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv28214

Modified Files:
	mbox-sync-parse.c 
Log Message:
Handle duplicate keywords in X-Keywords header properly



Index: mbox-sync-parse.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mbox-sync-parse.c	27 Oct 2005 09:28:23 -0000	1.46
+++ mbox-sync-parse.c	28 Oct 2005 14:32:02 -0000	1.47
@@ -255,9 +255,10 @@
 			    struct message_header_line *hdr)
 {
 	array_t ARRAY_DEFINE(keyword_list, unsigned int);
+	const unsigned int *list;
 	string_t *keyword;
 	size_t keyword_start;
-	unsigned int idx;
+	unsigned int i, idx, count;
 	size_t pos;
 
 	if (array_is_created(&ctx->mail.keywords))
@@ -292,7 +293,16 @@
 			return FALSE;
 		}
 
-		array_append(&keyword_list, &idx, 1);
+		/* check that the keyword isn't already added there.
+		   we don't want duplicates. */
+		list = array_get(&keyword_list, &count);
+		for (i = 0; i < count; i++) {
+			if (list[i] == idx)
+				break;
+		}
+
+		if (i == count)
+			array_append(&keyword_list, &idx, 1);
 	}
 
 	/* once we know how many keywords there are, we can allocate the array



More information about the dovecot-cvs mailing list