]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3-migration: Replace trailing whitespace removal with new header hashing version
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 23 Jun 2017 08:02:24 +0000 (11:02 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 26 Jun 2017 08:54:23 +0000 (11:54 +0300)
This is now done by message_header_hash(), which makes it work correctly
also for dsync+imapc.

Reverts 0cf3b30b86e6c39f43b8e13a718cd078187ca86d, except for the unit tests.

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

index 4a4f6a42a24e1ccf6c34198075d17ee65410f732..59f30f761412381fc6f6d4447b597fa91499ff5f 100644 (file)
@@ -171,21 +171,7 @@ pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED,
                        /* Yahoo IMAP drops headers with invalid names, while
                           Yahoo POP3 preserves them. Drop them all. */
                        *matched = TRUE;
-               } else if (hdr->value_len > 0 &&
-                          hdr->value[hdr->value_len-1] == ' ') T_BEGIN {
-                       /* Delete trailing whitespace. Zimbra is stripping it
-                          away with BODY[HEADER]. */
-                       struct message_header_line new_hdr = *hdr;
-                       while (new_hdr.value_len > 0 &&
-                              new_hdr.value[new_hdr.value_len-1] == ' ')
-                               new_hdr.value_len--;
-                       new_hdr.crlf_newline = FALSE; /* CRs are stripped */
-                       string_t *new_line = t_str_new(128);
-                       message_header_line_write(new_line, &new_hdr);
-                       i_stream_header_filter_add(input, str_data(new_line),
-                                                  str_len(new_line));
-                       *matched = TRUE;
-               } T_END;
+               }
        }
 }
 
@@ -208,8 +194,10 @@ int pop3_migration_get_hdr_sha1(uint32_t mail_seq, struct istream *input,
                                pop3_header_filter_callback, &hdr_ctx);
 
        sha1_init(&sha1_ctx);
+       i_zero(&hash_ctx);
        while (i_stream_read_data(input, &data, &size, 0) > 0) {
-               message_header_hash_more(&hash_ctx, &hash_method_sha1, &sha1_ctx, 2,
+               message_header_hash_more(&hash_ctx, &hash_method_sha1, &sha1_ctx,
+                                        MESSAGE_HEADER_HASH_MAX_VERSION,
                                         data, size);
                i_stream_skip(input, size);
        }
index 49d6c87808f0ea161509aabd8c21759cd89e7ed8..9469823a082e06ed29dfacfddd40ecb2c18af7bf 100644 (file)
@@ -16,13 +16,14 @@ static void test_pop3_migration_get_hdr_sha1(void)
        } tests[] = {
                { "", "da39a3ee5e6b4b0d3255bfef95601890afd80709", FALSE },
                { "\n", "adc83b19e793491b1c6ea0fd8b46cd9f32e592fc", TRUE },
-               { "a: b\r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", FALSE },
-               { "a: b \r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", FALSE },
-               { "a: b  \r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", FALSE },
-               { "a: b     \r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", FALSE },
-               { "a: b\r\n\r\n", "d14841695e1d9e2de6625d9222abd149ec821b0d", TRUE },
-               { "a: b\r\n\r\r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", FALSE },
-               { "a: b\r\n\r\r\nc: d\r\n\r\n", "3edb5ce145cf1d1e2413e02b8bed70f1ae3ed105", TRUE }
+               { "a: \r\n", "a3871371f2d468493005286282ae10549dab2c57", FALSE },
+               { "a: b\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
+               { "a: b \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
+               { "a: b  \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
+               { "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 }
        };
        struct istream *input;
        unsigned char digest[SHA1_RESULTLEN];