Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3701:e9742e1f3741 HEAD
Handle duplicate keywords in X-Keywords header properly
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 28 Oct 2005 17:32:02 +0300 |
parents | 5ca6f0751346 |
children | 50e6aeff6b6d |
files | src/lib-storage/index/mbox/mbox-sync-parse.c |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-parse.c Fri Oct 28 17:16:16 2005 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync-parse.c Fri Oct 28 17:32:02 2005 +0300 @@ -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