]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
message_id_get_next() didn't contain @ in reply when msgid wasn't in canonical form.
authorTimo Sirainen <tss@iki.fi>
Mon, 1 Jun 2009 04:41:23 +0000 (00:41 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 1 Jun 2009 04:41:23 +0000 (00:41 -0400)
--HG--
branch : HEAD

src/lib-mail/Makefile.am
src/lib-mail/message-id.c
src/lib-mail/test-message-id.c [new file with mode: 0644]

index 828cf85468eeb28f543b493cb721765db410941a..9ed0be4a8c9fc9281a7ca86394728694aa9bcc01 100644 (file)
@@ -55,6 +55,7 @@ test_programs = \
        test-message-address \
        test-message-date \
        test-message-header-parser \
+       test-message-id \
        test-message-parser \
        test-rfc2231-parser
 
@@ -84,6 +85,10 @@ test_message_header_parser_SOURCES = test-message-header-parser.c
 test_message_header_parser_LDADD = message-header-parser.lo $(test_libs)
 test_message_header_parser_DEPENDENCIES = message-header-parser.lo $(test_libs)
 
+test_message_id_SOURCES = test-message-id.c
+test_message_id_LDADD = message-id.lo rfc822-parser.lo $(test_libs)
+test_message_id_DEPENDENCIES = message-id.lo rfc822-parser.lo $(test_libs)
+
 test_message_parser_SOURCES = test-message-parser.c
 test_message_parser_LDADD = message-parser.lo message-header-parser.lo message-size.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs)
 test_message_parser_DEPENDENCIES = message-parser.lo message-header-parser.lo message-size.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs)
index 90e10c79551374fe29bce230a9e023ca7c3cbc9f..33f8248841b0df5ee7d61758609a384b2cbd5e67 100644 (file)
@@ -27,6 +27,7 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid)
 
        if (*parser.data != '@')
                return FALSE;
+       str_append_c(msgid, '@');
        parser.data++;
        (void)rfc822_skip_lwsp(&parser);
 
diff --git a/src/lib-mail/test-message-id.c b/src/lib-mail/test-message-id.c
new file mode 100644 (file)
index 0000000..01b2006
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "message-id.h"
+#include "test-common.h"
+
+static void test_message_id_get_next(void)
+{
+       const char *input[] = {
+               "<foo@bar>",
+               "<foo@bar>,skipped,<foo2@bar2>",
+               "(c) < (c) foo (c) @ (c) bar (c) > (c)",
+       };
+       const char *output[] = {
+               "foo@bar", NULL,
+               "foo@bar", "foo2@bar2", NULL,
+               "foo@bar", NULL
+       };
+       const char *msgid, *next_msgid;
+       unsigned int i, j;
+
+       test_begin("message id parser");
+       for (i = 0, j = 0; i < N_ELEMENTS(input); i++) {
+               msgid = input[i];
+               while ((next_msgid = message_id_get_next(&msgid)) != NULL)
+                       test_assert(strcmp(output[j++], next_msgid) == 0);
+               test_assert(output[j++] == NULL);
+       }
+       test_assert(j == N_ELEMENTS(output));
+       test_end();
+}
+
+int main(void)
+{
+       static void (*test_functions[])(void) = {
+               test_message_id_get_next,
+               NULL
+       };
+       return test_run(test_functions);
+}