diff --git a/src/config.h b/src/config.h index 31873d65..a1adee6d 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.20" -#define BUILD 691 +#define BUILD 697 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index 011939bc..397f1416 100644 --- a/src/parser.c +++ b/src/parser.c @@ -165,23 +165,26 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->is_1st_header == 1 && state->ms_journal == 0 && strncmp(buf, "X-MS-Journal-Report:", strlen("X-MS-Journal-Report:")) == 0){ state->ms_journal = 1; memset(state->message_id, 0, SMALLBUFSIZE); + + memset(state->b_from, 0, SMALLBUFSIZE); + memset(state->b_from_domain, 0, SMALLBUFSIZE); } - //printf("buf: %s", buf); if(state->message_rfc822 == 0 && (buf[0] == '\r' || buf[0] == '\n') ){ state->message_state = MSG_BODY; if(state->is_header == 1) state->is_header = 0; state->is_1st_header = 0; - - - if(state->ms_journal == 1){ - state->is_1st_header = 1; - state->is_header = 1; - } } + if(state->ms_journal == 1 && strncasecmp(buf, "Received:", strlen("Received:")) == 0){ + state->is_1st_header = 1; + state->is_header = 1; + memset(state->b_body, 0, BIGBUFSIZE); + state->bodylen = 0; + memset(state->b_subject, 0, MAXBUFSIZE); + } if(take_into_pieces == 1){ if(state->message_state == MSG_BODY && state->fd != -1 && is_item_on_string(state->boundaries, buf) == 0){ @@ -267,8 +270,8 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int return 0; } - trimBuffer(buf); + trimBuffer(buf); /* skip the first line, if it's a "From date" format */ if(state->line_num == 1 && strncmp(buf, "From ", 5) == 0) return 0; @@ -314,6 +317,12 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int } + if(state->message_state == MSG_BODY && state->ms_journal == 1 && strncasecmp(buf, "Recipient:", strlen("Recipient:")) == 0){ + state->is_header = 1; + state->is_1st_header = 1; + state->message_state = MSG_RECIPIENT; + } + if(state->message_state == MSG_RECIPIENT){ p = strstr(buf, "Expanded:"); if(p) *p = '\0'; @@ -486,7 +495,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->is_header == 1) p = strchr(buf, ' '); else p = buf; - //printf("a: *%s*\n", buf); + //printf("a: %d/%d/%d/%d %s\n", state->is_1st_header, state->is_header, state->message_rfc822, state->message_state, buf); do { memset(puf, 0, sizeof(puf)); diff --git a/src/parser_utils.c b/src/parser_utils.c index ce8635ad..6d040d40 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -525,6 +525,8 @@ void translateLine(unsigned char *p, struct _state *state){ if(url == 1) url = 0; } + if(*p == '@') *p = 'X'; + if(delimiter_characters[(unsigned int)*p] != ' ') *p = ' '; /* we MUSTN'T convert it to lowercase in the 'else' case, because it breaks utf-8 encoding! */