Skip to content

Commit

Permalink
pop3-migration: Drop lines with only spaces or tabs from comparison
Browse files Browse the repository at this point in the history
Zimbra drops out those lines from IMAP BODY[HEADER] replies.
  • Loading branch information
sirainen committed Jun 28, 2017
1 parent d4f77de commit 29fc8f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/plugins/pop3-migration/pop3-migration-plugin.c
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/pop3-migration/test-pop3-migration-plugin.c
Expand Up @@ -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];
Expand Down

0 comments on commit 29fc8f1

Please sign in to comment.