Mercurial > dovecot > core-2.2
changeset 19691:69502e2013f3
pop3-migration: Use message_header_hash_more() instead of duplicating the code
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 01 Feb 2016 17:57:07 +0200 |
parents | f2430d582c74 |
children | f1265c5c323a |
files | src/plugins/pop3-migration/pop3-migration-plugin.c |
diffstat | 1 files changed, 4 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/pop3-migration/pop3-migration-plugin.c Mon Feb 01 17:56:49 2016 +0200 +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c Mon Feb 01 17:57:07 2016 +0200 @@ -7,6 +7,7 @@ #include "str.h" #include "sha1.h" #include "message-size.h" +#include "message-header-hash.h" #include "message-header-parser.h" #include "mail-cache.h" #include "mail-namespace.h" @@ -181,7 +182,7 @@ { struct istream *input2; const unsigned char *data; - size_t i, start, size; + size_t size; struct sha1_ctxt sha1_ctx; struct pop3_hdr_context hdr_ctx; @@ -197,28 +198,8 @@ sha1_init(&sha1_ctx); while (i_stream_read_data(input, &data, &size, 0) > 0) { - /* - Dovecot IMAP replaces NULs with 0x80 character. - - Dovecot POP3 with outlook-no-nuls workaround replaces NULs - with 0x80 character. - - Zimbra replaces 8bit chars with '?' in header fetches, - but not body fetches. - - Yahoo replaces 8bit chars with '?' in partial header - fetches, but not POP3 TOP. - - So we'll just replace all control and 8bit chars with '?', - which hopefully will satisfy everybody. - - (Keep this code in sync with dsync.) - */ - for (i = start = 0; i < size; i++) { - if ((data[i] < 0x20 || data[i] >= 0x80) && - (data[i] != '\t' && data[i] != '\n')) { - sha1_loop(&sha1_ctx, data + start, i-start); - sha1_loop(&sha1_ctx, "?", 1); - start = i+1; - } - } - sha1_loop(&sha1_ctx, data + start, i-start); + message_header_hash_more(&hash_method_sha1, &sha1_ctx, 2, + data, size); i_stream_skip(input, size); } if (input->stream_errno != 0) {