From: Timo Sirainen Date: Mon, 4 Sep 2017 09:40:49 +0000 (+0300) Subject: pop3-migration: Strip away invalid header lines. X-Git-Tag: 2.3.0.rc1~1114 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cefa6f3df2f30d84f8279109e9152cada9f67e16;p=thirdparty%2Fdovecot%2Fcore.git pop3-migration: Strip away invalid header lines. If there's no ":" in the header, remove it. Fixes matching mails with Zimbra. --- diff --git a/src/plugins/pop3-migration/pop3-migration-plugin.c b/src/plugins/pop3-migration/pop3-migration-plugin.c index 4f5f877f4c..85d884fcb9 100644 --- a/src/plugins/pop3-migration/pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c @@ -184,6 +184,10 @@ pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED, here while others don't. To make sure they can be matched correctly we want to stop here entirely. */ ctx->stop = TRUE; + } else if (!hdr->continued && hdr->middle_len == 0) { + /* not a valid "key: value" header - + Zimbra's BODY[HEADER] strips this line away. */ + *matched = TRUE; } else if (hdr->continued && header_value_want_skip(hdr)) { *matched = TRUE; } diff --git a/src/plugins/pop3-migration/test-pop3-migration-plugin.c b/src/plugins/pop3-migration/test-pop3-migration-plugin.c index c4c00e0f82..439e3e087d 100644 --- a/src/plugins/pop3-migration/test-pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/test-pop3-migration-plugin.c @@ -28,6 +28,11 @@ static void test_pop3_migration_get_hdr_sha1(void) { "a: b\r\n \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, { "a: b\r\n\t\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, { "a: b\t\t\t\t\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, + { "a: b\nfoo\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, + + { "a: b\nc: d\n", "4dbea2c1bdd1323e15931382c1835200d9286230", FALSE }, + { "a:b\nc:d\n", "4dbea2c1bdd1323e15931382c1835200d9286230", FALSE }, + { "a: b\nfoo\nc: d\n", "4dbea2c1bdd1323e15931382c1835200d9286230", FALSE }, }; struct istream *input; unsigned char digest[SHA1_RESULTLEN];