Skip to content

Commit

Permalink
lib-mail: Fixed istream-header-filter callback's matched with eoh
Browse files Browse the repository at this point in the history
Reversed the matched-parameter handling for hdr->eoh, so it's consistent
with non-eoh headers.
  • Loading branch information
sirainen authored and GitLab committed May 16, 2016
1 parent 2a444bf commit 44ef494
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib-mail/istream-header-filter.c
Expand Up @@ -197,7 +197,7 @@ static ssize_t read_header(struct header_filter_istream *mstream)
mstream->cur_line++;
if (hdr->eoh) {
mstream->seen_eoh = TRUE;
matched = TRUE;
matched = FALSE;
if (mstream->header_parsed && !mstream->headers_edited) {
if (mstream->eoh_not_matched)
matched = !matched;
Expand All @@ -206,7 +206,7 @@ static ssize_t read_header(struct header_filter_istream *mstream)
mstream->context);
}

if (!matched) {
if (matched) {
mstream->seen_eoh = FALSE;
mstream->eoh_not_matched = TRUE;
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/lib-mail/test-istream-header-filter.c
Expand Up @@ -266,7 +266,7 @@ edit_callback(struct header_filter_istream *input,
/* add a new header */
const char *new_hdr = "Added: header\n\n";
i_stream_header_filter_add(input, new_hdr, strlen(new_hdr));
*matched = FALSE;
*matched = TRUE;
} else if (strcasecmp(hdr->name, "To") == 0) {
/* modify To header */
const char *new_to = "To: 123\n";
Expand Down Expand Up @@ -434,7 +434,7 @@ strip_eoh_callback(struct header_filter_istream *input ATTR_UNUSED,
bool *matched, void *context ATTR_UNUSED)
{
if (hdr != NULL && hdr->eoh)
*matched = FALSE;
*matched = TRUE;
}

static void test_istream_strip_eoh(void)
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/pop3-migration/pop3-migration-plugin.c
Expand Up @@ -153,11 +153,8 @@ pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED,
return;
if (hdr->eoh) {
ctx->have_eoh = TRUE;
if (ctx->stop) {
/* matched is handled differently for eoh by
istream-header-filter. a design bug I guess.. */
*matched = FALSE;
}
if (ctx->stop)
*matched = TRUE;
} else {
if (strspn(hdr->name, "\r") == hdr->name_len) {
/* CR+CR+LF - some servers stop the header processing
Expand Down

0 comments on commit 44ef494

Please sign in to comment.