Mercurial > dovecot > core-2.2
changeset 15062:9935621836c8
lib-imap: Fixed Content-Language parsing from BODYSTRUCTURE
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 15 Sep 2012 19:12:04 +0300 |
parents | 108b28e864c4 |
children | 0efc12f3eb2a |
files | src/lib-imap/imap-bodystructure.c src/lib-imap/test-imap-bodystructure.c |
diffstat | 2 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap/imap-bodystructure.c Sat Sep 15 19:08:55 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.c Sat Sep 15 19:12:04 2012 +0300 @@ -567,11 +567,7 @@ while (!IMAP_ARG_IS_EOL(args)) { if (!str_append_nstring(str, &args[0])) return -1; - str_append_c(str, ' '); - if (!str_append_nstring(str, &args[1])) - return -1; - - args += 2; + args++; if (IMAP_ARG_IS_EOL(args)) break; str_append_c(str, ' '); @@ -580,15 +576,19 @@ } static int imap_write_params(const struct imap_arg *arg, pool_t pool, - string_t *tmpstr, const char **value_r) + string_t *tmpstr, unsigned int divisible, + const char **value_r) { const struct imap_arg *list_args; + unsigned int list_count; if (arg->type == IMAP_ARG_NIL) { *value_r = NULL; return 0; } - if (!imap_arg_get_list(arg, &list_args)) + if (!imap_arg_get_list_full(arg, &list_args, &list_count)) + return -1; + if ((list_count % divisible) != 0) return -1; if (imap_write_nstring_list(list_args, tmpstr) < 0) @@ -636,14 +636,14 @@ *error_r = "Invalid content-disposition"; return -1; } - if (imap_write_params(list_args, pool, tmpstr, + if (imap_write_params(list_args, pool, tmpstr, 2, &data->content_disposition_params) < 0) { *error_r = "Invalid content-disposition params"; return -1; } args++; } - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 1, &data->content_language) < 0) { *error_r = "Invalid content-language"; return -1; @@ -703,7 +703,7 @@ *error_r = "Invalid multipart content-type"; return -1; } - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 2, &data->content_type_params) < 0) { *error_r = "Invalid content params"; return -1; @@ -741,7 +741,7 @@ } /* ("content type param key" "value" ...) | NIL */ - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 2, &data->content_type_params) < 0) { *error_r = "Invalid content params"; return -1;
--- a/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:08:55 2012 +0300 +++ b/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:12:04 2012 +0300 @@ -22,7 +22,7 @@ "Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==\n" "Content-Disposition: inline; foo=bar\n" "Content-Description: hellodescription\n" -"Content-Language: en, fi\n" +"Content-Language: en, fi, se\n" "Content-Location: http://example.com/test.txt\n" "\n" "hello\n" @@ -55,7 +55,7 @@ static const char testmsg_bodystructure[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n" -"quoted\"string) \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; +"quoted\"string) \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\" \"se\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; static const char testmsg_body[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n"