Mercurial > dovecot > core-2.2
changeset 3288:1fae8494f8f7 HEAD
mail_get_headers() and mail_get_first_header() returned headers with "name:"
prefix if they weren't in cache file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 12 Apr 2005 12:56:33 +0300 |
parents | 47437871d879 |
children | 92dd47097bc8 |
files | src/lib-storage/index/index-mail-headers.c |
diffstat | 1 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail-headers.c Tue Apr 12 11:37:26 2005 +0300 +++ b/src/lib-storage/index/index-mail-headers.c Tue Apr 12 12:56:33 2005 +0300 @@ -427,12 +427,33 @@ return -1; } +static int skip_header(const unsigned char **data, size_t len) +{ + const unsigned char *p = *data; + size_t i; + + for (i = 0; i < len; i++) { + if (p[i] == ':') + break; + } + if (i == len) + return FALSE; + + for (i++; i < len; i++) { + if (!IS_LWSP(p[i])) + break; + } + + *data = p + i; + return TRUE; +} + static const char *const * index_mail_get_parsed_header(struct index_mail *mail, unsigned int field_idx) { array_t ARRAY_DEFINE(header_values, const char *); const struct index_mail_line *lines; - const unsigned char *header; + const unsigned char *header, *value_start, *value_end; const unsigned int *line_idx; const char *value; unsigned int i, lines_count, first_line_idx; @@ -449,9 +470,16 @@ if (lines[i].field_idx != lines[first_line_idx].field_idx) break; - value = p_strndup(mail->data_pool, header + lines[i].start_pos, - lines[i].end_pos - lines[i].start_pos); - array_append(&header_values, &value, 1); + /* skip header: and drop ending LF */ + value_start = header + lines[i].start_pos; + value_end = header + lines[i].end_pos; + if (skip_header(&value_start, value_end - value_start)) { + if (value_start != value_end && value_end[-1] == '\n') + value_end--; + value = p_strndup(mail->data_pool, value_start, + value_end - value_start); + array_append(&header_values, &value, 1); + } } value = NULL;