]> 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 13:04:21 +0000 (16:04 +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 59f30f761412381fc6f6d4447b597fa91499ff5f..288ad723d2a0c79f3b05890bca0c5a9df75313f2 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,
@@ -164,6 +174,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 9469823a082e06ed29dfacfddd40ecb2c18af7bf..15ff6f58fc864c54a29184c06455521f1a39628c 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];