From 66db430f247cb76833450f590653dd600aa4d481 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 9 Jan 2015 12:00:59 +0100 Subject: [PATCH] better parsing of multiline subjects --- src/config.h | 2 +- src/parser.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/config.h b/src/config.h index f2ef3f9c..8d8f0f47 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "1.1.1-pre" -#define BUILD 898 +#define BUILD 899 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index 5e3c9c47..6cb4f2e9 100644 --- a/src/parser.c +++ b/src/parser.c @@ -452,16 +452,21 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int } else { - p = strrchr(state->b_subject, ' '); - if(p && ( strcasestr(p+1, "?Q?") || strcasestr(p+1, "?B?") ) ){ - strncat(state->b_subject, buf+1, MAXBUFSIZE-1); + /* + * if the next subject line is encoded, then strip the whitespace characters at the beginning of the line + */ + + p = buf; + + if(strcasestr(buf, "?Q?") || strcasestr(buf, "?B?")){ + while(isspace(*p)) p++; } - else strncat(state->b_subject, buf, MAXBUFSIZE-1); + strncat(state->b_subject, p, MAXBUFSIZE-1); } - } + if(state->is_1st_header == 1){ fixupEncodedHeaderLine(buf, MAXBUFSIZE); }