Mercurial > dovecot > core-2.2
changeset 22363:dba5febb1752
lib-mail: message_header_hash() - add v4 that strips tabs
This helps with Zimbra, which strips away trailing tabs in BODY[HEADER].
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 19 Jul 2017 10:57:36 +0300 |
parents | 5e665ab8487c |
children | cd3e74d1002f |
files | src/lib-mail/message-header-hash.c src/lib-mail/message-header-hash.h src/lib-mail/test-message-header-hash.c |
diffstat | 3 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-header-hash.c Tue Jul 18 14:42:23 2017 +0300 +++ b/src/lib-mail/message-header-hash.c Wed Jul 19 10:57:36 2017 +0300 @@ -30,22 +30,28 @@ remove any repeated '?', which hopefully will satisfy everybody. Also: - - Zimbra removes trailing spaces from IMAP BODY[HEADER], but not - IMAP BODY[] or POP3 TOP. Just strip away all spaces with version 3. - + - Zimbra removes trailing spaces and tabs from IMAP BODY[HEADER], + but not IMAP BODY[] or POP3 TOP. Just strip away all spaces with + version 3 and tabs also with version 4. */ for (i = start = 0; i < size; i++) { bool cur_is_questionmark = FALSE; switch (data[i]) { case ' ': - if (version == 3) { + if (version >= 3) { /* strip away spaces */ method->loop(context, data + start, i-start); start = i+1; } break; case '\t': + if (version >= 4) { + /* strip away tabs */ + method->loop(context, data + start, i-start); + start = i+1; + } + break; case '\n': break; default:
--- a/src/lib-mail/message-header-hash.h Tue Jul 18 14:42:23 2017 +0300 +++ b/src/lib-mail/message-header-hash.h Wed Jul 19 10:57:36 2017 +0300 @@ -1,7 +1,7 @@ #ifndef MESSAGE_HEADER_HASH_H #define MESSAGE_HEADER_HASH_H -#define MESSAGE_HEADER_HASH_MAX_VERSION 3 +#define MESSAGE_HEADER_HASH_MAX_VERSION 4 struct hash_method;
--- a/src/lib-mail/test-message-header-hash.c Tue Jul 18 14:42:23 2017 +0300 +++ b/src/lib-mail/test-message-header-hash.c Wed Jul 19 10:57:36 2017 +0300 @@ -31,12 +31,20 @@ { "? ? ? hi \x01\x02 \x03 ", 2, "? ? ? hi ? ? " }, { test_input_with_nuls, 3, "?\t\n?!?x?yz?-plop?" }, - { "\n\nhi\n\n", 2, "\n\nhi\n\n" }, + { "\n\nhi\n\n", 3, "\n\nhi\n\n" }, { "", 3, "" }, { " ", 3, "" }, { " ", 3, "" }, { " ? ", 3, "?" }, { "? ? ? hi \x01\x02 \x03 ", 3, "???hi??" }, + { " \t \t", 3, "\t\t" }, + + { test_input_with_nuls, 4, "?\n?!?x?yz?-plop?" }, + { "\n\nhi\n\n", 4, "\n\nhi\n\n" }, + { "", 4, "" }, + { " ", 4, "" }, + { " \t \t", 4, "" }, + { "foo\t\t", 4, "foo" }, }; static void test_message_header_hash_more(void)