From: Timo Sirainen Date: Wed, 28 Jun 2017 12:50:11 +0000 (+0300) Subject: pop3-migration: Drop lines with only spaces or tabs from comparison X-Git-Tag: 2.3.0.rc1~1375 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29fc8f1dc678f9698363181ea599e6db105ea50f;p=thirdparty%2Fdovecot%2Fcore.git pop3-migration: Drop lines with only spaces or tabs from comparison Zimbra drops out those lines from IMAP BODY[HEADER] replies. --- diff --git a/src/plugins/pop3-migration/pop3-migration-plugin.c b/src/plugins/pop3-migration/pop3-migration-plugin.c index ea9011f230..01806da8b7 100644 --- a/src/plugins/pop3-migration/pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c @@ -144,6 +144,16 @@ static bool header_name_is_valid(const char *name) return TRUE; } +static bool header_value_want_skip(const struct message_header_line *hdr) +{ + for (size_t i = 0; i < hdr->value_len; i++) { + if (hdr->value[i] != ' ' && hdr->value[i] != '\t') + return FALSE; + } + /* "header: \r\n \r\n" - Zimbra's BODY[HEADER] strips this line away. */ + return TRUE; +} + static void pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED, struct message_header_line *hdr, @@ -161,6 +171,8 @@ 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 && header_value_want_skip(hdr)) { + *matched = TRUE; } if (ctx->stop) *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 369b5fecd7..0f6fe64e16 100644 --- a/src/plugins/pop3-migration/test-pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/test-pop3-migration-plugin.c @@ -23,7 +23,10 @@ static void test_pop3_migration_get_hdr_sha1(void) { "a: b \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, { "a: b\r\n\r\n", "938b96404495cced816e3a4f6031734eab4e71b3", TRUE }, { "a: b\r\n\r\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, - { "a: b\r\n\r\r\nc: d\r\n\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", TRUE } + { "a: b\r\n\r\r\nc: d\r\n\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", TRUE }, + { "a: b\r\n \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, + { "a: b\r\n \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, + { "a: b\r\n\t\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE }, }; struct istream *input; unsigned char digest[SHA1_RESULTLEN];