#include #include #include #include #include #include #include #include "camel-test.h" /* NB: We know which order the params will be decoded in, plain in the order they come, and rfc2184 encoded following those, sorted lexigraphically */ struct { char *list; int count; char *params[8]; } test1[] = { { "; charset=\"iso-8859-1\"", 1, { "charset", "iso-8859-1" }, }, { "; charset=iso-8859-1", 1, { "charset", "iso-8859-1" }, }, { "; charset=\"iso-8859-1\"; boundary=\"foo\"", 2, { "charset", "iso-8859-1", "boundary", "foo" }, }, { "; charset*1 = 8859; charset*0=\"iso-8859-1'en'iso-\";charset*2=\"-1\" ", 1, { "charset", "iso-8859-1" }, }, { "; charset*1 = 8859; boundary=foo; charset*0=\"iso-8859-1'en'iso-\";charset*2=\"-1\" ", 2, { "boundary", "foo", "charset", "iso-8859-1", }, }, { "; charset*1 = 8859; boundary*0=f; charset*0=\"iso-8859-1'en'iso-\"; boundary*2=\"o\" ; charset*2=\"-1\"; boundary*1=o ", 2, { "boundary", "foo", "charset", "iso-8859-1", }, }, { "; charset*1 = 8859; boundary*0=\"iso-8859-1'en'f\"; charset*0=\"iso-8859-1'en'iso-\"; boundary*2=\"o\" ; charset*2=\"-1\"; boundary*1=o ", 2, { "boundary", "foo", "charset", "iso-8859-1", }, }, }; struct { int count; char *params[8]; char *list; } test2[] = { { 1, { "name", "Doul\xC3\xADk01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123457890123456789123456789" }, ";\n" "\tname*0*=iso-8859-1''Doul%EDk012345678901234567890123456789012345678901234;\n" "\tname*1*=56789012345678901234567890123456789012345678901234567890123457890;\n" "\tname*2*=123456789123456789" }, { 1, { "name", "\"%$#@ special chars?;; !" }, "; name=\"\\\"%$#@ special chars?;; !\"" }, { 1, { "name", "\"%$#@ special chars?;; !\xC3\xAD" }, "; name*=iso-8859-1''%22%25$#%40%20special%20chars%3F%3B%3B%20!%ED" }, }; int main (int argc, char **argv) { int i, j; camel_test_init(argc, argv); camel_test_start("Param list decoding"); for (i=0;iname, test1[i].params[j*2]) == 0); check(strcmp(node->value, test1[i].params[j*2+1]) == 0); node = node->next; } check_msg(node == NULL, "found more params than should have"); camel_header_param_list_free(head); camel_test_pull(); } camel_test_end(); camel_test_start("Param list encoding"); for (i=0;inext; check(j == test2[i].count); text = camel_header_param_list_format(head); check(strcmp(text, test2[i].list) == 0); camel_header_param_list_free(head); camel_test_pull(); } camel_test_end(); return 0; }