summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J Stevens <paul@nfg.nl>2009-02-24 16:19:34 +0100
committerPaul J Stevens <paul@nfg.nl>2009-02-24 16:19:34 +0100
commit45ba60dea854c4649a9b1cf116210c74495f8868 (patch)
tree2dac96ddf5c434353087ceacc88279a7b37547b9
parent09c9f56b2dd4a43a134a30adb8fc92065bd3eb04 (diff)
imap-envelope fixes
-rw-r--r--src/dm_misc.c2
-rw-r--r--src/imap4.c4
-rw-r--r--test/check_dbmail.h8
-rw-r--r--test/check_dbmail_imapd.c49
4 files changed, 47 insertions, 16 deletions
diff --git a/src/dm_misc.c b/src/dm_misc.c
index 006ef30c..c4e65877 100644
--- a/src/dm_misc.c
+++ b/src/dm_misc.c
@@ -1707,7 +1707,7 @@ GList* dbmail_imap_append_alist_as_plist(GList *list, const InternetAddressList
t = NULL;
/* Address list ending. */
- // p = g_list_append_printf(p, "(NIL NIL NIL NIL)", ia->name);
+ p = g_list_append_printf(p, "(NIL NIL NIL NIL)");
break;
diff --git a/src/imap4.c b/src/imap4.c
index 822eac51..6296c0d3 100644
--- a/src/imap4.c
+++ b/src/imap4.c
@@ -74,6 +74,7 @@ const IMAP_COMMAND_HANDLER imap_handler_functions[] = {
static int imap4_tokenizer(ImapSession *, char *);
static int imap4(ImapSession *);
+static void imap_handle_input(ImapSession *);
static void imap_session_bailout(ImapSession *session)
{
@@ -118,6 +119,7 @@ void socket_write_cb(int fd UNUSED, short what, void *arg)
// continuation '+' to the client
session->command_state = IDLE;
event_add(session->ci->rev, NULL);
+ imap_handle_input(session);
} else if (session->command_state == TRUE) { // IDLE is done
event_add(session->ci->rev, session->ci->timeout);
}
@@ -251,7 +253,7 @@ static void imap_handle_exit(ImapSession *session, int status)
}
}
-static void imap_handle_input(ImapSession *session)
+void imap_handle_input(ImapSession *session)
{
char buffer[MAX_LINESIZE];
int l, result;
diff --git a/test/check_dbmail.h b/test/check_dbmail.h
index 906852d8..3f6cb604 100644
--- a/test/check_dbmail.h
+++ b/test/check_dbmail.h
@@ -41,6 +41,14 @@ char *simple_with_from = "From nobody@pacific.net.sg Tue Dec 04 19:52:17 2007\n"
"This line gets truncated\n"
"This other line get truncated too\n";
+char *simple_groups = "From user@domain Fri Feb 22 17:06:23 2008\n"
+ "Date: Thu, 15 Feb 2007 01:02:03 +0200\n"
+ "From: user@domain (Real Name)\n"
+ "To: group: g1@d1.org, g2@d2.org;, group2: g3@d3.org;\n"
+ "\n"
+ "body\n"
+ "\n";
+
char *rfc822 = "From nobody Wed Sep 14 16:47:48 2005\n"
"Content-Type: text/plain; charset=\"us-ascii\"\n"
"MIME-Version: 1.0\n"
diff --git a/test/check_dbmail_imapd.c b/test/check_dbmail_imapd.c
index a5f7d7c7..7940f640 100644
--- a/test/check_dbmail_imapd.c
+++ b/test/check_dbmail_imapd.c
@@ -266,7 +266,7 @@ START_TEST(test_imap_get_structure)
message = dbmail_message_init_with_string(message, g_string_new(multipart_message));
result = imap_get_structure(GMIME_MESSAGE(message->content), 1);
strncpy(expect,"((\"text\" \"html\" NIL NIL NIL \"7BIT\" 16 1 NIL (\"inline\" NIL) NIL NIL)"
- "(\"text\" \"plain\" (\"name\" \"testfile\" \"charset\" \"us-ascii\") NIL NIL \"base64\" 432 7 NIL NIL NIL NIL)"
+ "(\"text\" \"plain\" (\"charset\" \"us-ascii\" \"name\" \"testfile\") NIL NIL \"base64\" 432 7 NIL NIL NIL NIL)"
" \"mixed\" (\"boundary\" \"boundary\") NIL NIL NIL)",1024);
fail_unless(strncasecmp(result,expect,1024)==0, "imap_get_structure failed\n[%s] !=\n[%s]\n", expect, result);
g_free(result);
@@ -297,21 +297,26 @@ END_TEST
START_TEST(test_internet_address_parse_string)
{
- char * trythese [] = { "undisclosed-recipients", "undisclosed-recipients;",
- "undisclosed-recipients:", "undisclosed-recipients:;",
- "undisclosed-recipients: ;", NULL };
+ char * trythese [][2] = {
+ { "undisclosed-recipients", "((NIL NIL \"undisclosed-recipients\" NIL))"},
+ { "undisclosed-recipients;", "((NIL NIL \"undisclosed-recipients\" NIL))"},
+ { "undisclosed-recipients:", "((NIL NIL \"undisclosed-recipients\" NIL)(NIL NIL NIL NIL))"},
+ { "undisclosed-recipients:;", "((NIL NIL \"undisclosed-recipients\" NIL)(NIL NIL NIL NIL))"},
+ { "undisclosed-recipients: ;", "((NIL NIL \"undisclosed-recipients\" NIL)(NIL NIL NIL NIL))"},
+ { NULL, NULL }
+ };
int i;
- for (i = 0; trythese[i] != NULL; i++) {
+ for (i = 0; trythese[i][0] != NULL; i++) {
- char *result = trythese[i];
+ char *input = trythese[i][0];
+ char *expect = trythese[i][1];
+ char *t, *result;
- char *t;
InternetAddressList *alist;
- char *expect = "((NIL NIL \"undisclosed-recipients\" NIL))";
GList *list = NULL;
- t = imap_cleanup_address(result);
+ t = imap_cleanup_address(input);
alist = internet_address_parse_string(t);
g_free(t);
list = dbmail_imap_append_alist_as_plist(list, (const InternetAddressList *)alist);
@@ -320,7 +325,8 @@ START_TEST(test_internet_address_parse_string)
result = dbmail_imap_plist_as_string(list);
- fail_unless(strcmp(result,expect)==0, "internet_address_parse_string failed to generate correct undisclosed-recipients plist, expected [%s] got [%s]", expect, result);
+ fail_unless(strcmp(result,expect)==0, "internet_address_parse_string failed to generate correct undisclosed-recipients plist "
+ "for [%s], expected\n[%s] got\n[%s]", input, expect, result);
g_list_destroy(list);
g_free(result);
@@ -329,14 +335,14 @@ START_TEST(test_internet_address_parse_string)
char * testlist[][2] = {
{ "<i_am_not@broken.org>", "((NIL NIL \"i_am_not\" \"broken.org\"))" },
- { "Break me: <foo@bar.org>", "((NIL NIL \"Break me\" NIL)(NIL NIL \"foo\" \"bar.org\"))" },
+ { "Break me: <foo@bar.org>", "((NIL NIL \"Break me\" NIL)(NIL NIL \"foo\" \"bar.org\")(NIL NIL NIL NIL))" },
{ "Joe's Friends: mary@joe.com, joe@joe.com, jane@joe.com;",
"((NIL NIL \"Joe's Friends\" NIL)(NIL NIL \"mary\" \"joe.com\")"
- "(NIL NIL \"joe\" \"joe.com\")(NIL NIL \"jane\" \"joe.com\"))" },
+ "(NIL NIL \"joe\" \"joe.com\")(NIL NIL \"jane\" \"joe.com\")(NIL NIL NIL NIL))" },
// These have the wrong separator; ms lookout style.
{ "one@my.dom;two@my.dom", "((NIL NIL \"one\" \"my.dom\")(NIL NIL \"two\" \"my.dom\"))" },
{ "one@my.dom; two@my.dom", "((NIL NIL \"one\" \"my.dom\")(NIL NIL \"two\" \"my.dom\"))" },
- { "Group: one@my.dom;, two@my.dom", "((NIL NIL \"Group\" NIL)(NIL NIL \"one\" \"my.dom\")(NIL NIL \"two\" \"my.dom\"))" },
+ { "Group: one@my.dom;, two@my.dom", "((NIL NIL \"Group\" NIL)(NIL NIL \"one\" \"my.dom\")(NIL NIL NIL NIL)(NIL NIL \"two\" \"my.dom\"))" },
{ NULL, NULL }
};
@@ -403,9 +409,24 @@ START_TEST(test_imap_get_envelope)
g_free(result);
result = NULL;
+ /* bare bones message with group addresses*/
+ message = dbmail_message_new();
+ s = g_string_new(simple_groups);
+ message = dbmail_message_init_with_string(message, s);
+ g_string_free(s,TRUE);
+ result = imap_get_envelope(GMIME_MESSAGE(message->content));
+
+ strncpy(expect,"(\"Thu, 15 Feb 2007 01:02:03 +0200\" NIL ((\"Real Name\" NIL \"user\" \"domain\")) ((\"Real Name\" NIL \"user\" \"domain\")) ((\"Real Name\" NIL \"user\" \"domain\")) ((NIL NIL \"group\" NIL)(NIL NIL \"g1\" \"d1.org\")(NIL NIL \"g2\" \"d2.org\")(NIL NIL NIL NIL)(NIL NIL \"group2\" NIL)(NIL NIL \"g3\" \"d3.org\")(NIL NIL NIL NIL)) NIL NIL NIL NIL)", 1024);
+
+ fail_unless(strncasecmp(result,expect,1024)==0, "imap_get_envelope failed\n[%s] !=\n[%s]\n", result,expect);
+
+ dbmail_message_free(message);
+ g_free(result);
+ result = NULL;
+
+ //
g_free(expect);
expect = NULL;
-
}
END_TEST