]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3-migration: Drop lines with only spaces or tabs from comparison
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 28 Jun 2017 12:50:11 +0000 (15:50 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 28 Jun 2017 12:50:11 +0000 (15:50 +0300)
Zimbra drops out those lines from IMAP BODY[HEADER] replies.

src/plugins/pop3-migration/pop3-migration-plugin.c
src/plugins/pop3-migration/test-pop3-migration-plugin.c

index ea9011f23065656ead84a7055e664c2f11bddd37..01806da8b7e72103a6cf7db0480e6083d6f5392b 100644 (file)
@@ -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;
index 369b5fecd7a5d0c3cec22a404a2a0182f53824a1..0f6fe64e1680bf305c1ad8a4683edb970c570705 100644 (file)
@@ -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];