]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: Write invalid Content-Transfer-Encoding value as "7bit" to BODY/BODYSTRUCTURE.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Jan 2016 13:09:35 +0000 (15:09 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Jan 2016 13:12:13 +0000 (15:12 +0200)
src/lib-imap/imap-bodystructure.c
src/lib-imap/test-imap-bodystructure.c

index cce53fdb33b9f575e4417916a2f2405d550d9532..c0913567578f383cd0cbd61e8f449ccdccdbf625 100644 (file)
@@ -91,7 +91,8 @@ static void parse_content_transfer_encoding(struct message_part_body_data *data,
        rfc822_skip_lwsp(&parser);
 
        str = t_str_new(256);
-       if (rfc822_parse_mime_token(&parser, str) >= 0) {
+       if (rfc822_parse_mime_token(&parser, str) >= 0 &&
+           rfc822_skip_lwsp(&parser) == 0 && str_len(str) > 0) {
                data->content_transfer_encoding =
                        imap_get_string(data->pool, str_c(str));
        }
index 14618a5c6bd01f1e3ac6bbc435476d97baa3c29e..7a328dd4d39d1e88b81204a5cdf5edc2d4275be8 100644 (file)
@@ -44,6 +44,7 @@ static const char testmsg[] =
 "\n"
 "--sub1\n"
 "Content-Type: text/plain\n"
+"Content-Transfer-Encoding: ?invalid\n"
 "\n"
 "Hello another world\n"
 "\n"
@@ -54,10 +55,10 @@ static const char testmsg[] =
 "Root MIME epilogue\n";
 
 static const char testmsg_bodystructure[] =
-"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"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";
+"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"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\" 368 (\"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) 20 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL";
 
 static const char testmsg_body[] =
-"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"quoted\\\"string\") \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1)(\"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)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1) \"alternative\") 19) \"mixed\"";
+"(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" \"quoted\\\"string\") \"<foo@example.com>\" \"hellodescription\" \"7bit\" 7 1)(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 368 (\"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)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1) \"alternative\") 20) \"mixed\"";
 
 static struct message_part *msg_parse(pool_t pool, bool parse_bodystructure)
 {