diff --git a/src/defs.h b/src/defs.h index 3902d306..14e5779b 100644 --- a/src/defs.h +++ b/src/defs.h @@ -39,6 +39,7 @@ #define MSG_CONTENT_DISPOSITION 8 #define MSG_MESSAGE_ID 9 #define MSG_REFERENCES 10 +#define MSG_RECIPIENT 11 #define MAXHASH 8171 @@ -157,6 +158,7 @@ struct _state { int bodylen; int tolen; + char ms_journal; }; @@ -226,7 +228,7 @@ struct memcached_server { struct __data { int folder; - + char recursive_folder_names; #ifdef HAVE_TRE struct rule *archiving_rules; struct rule *retention_rules; diff --git a/src/parser.c b/src/parser.c index eb3c8d68..011939bc 100644 --- a/src/parser.c +++ b/src/parser.c @@ -162,6 +162,11 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int sdata->spam_message = 1; } + 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); + } + //printf("buf: %s", buf); if(state->message_rfc822 == 0 && (buf[0] == '\r' || buf[0] == '\n') ){ @@ -169,6 +174,12 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int 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; + } } @@ -282,6 +293,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int else if(strncasecmp(buf, "Message-Id:", 11) == 0) state->message_state = MSG_MESSAGE_ID; else if(strncasecmp(buf, "References:", 11) == 0) state->message_state = MSG_REFERENCES; else if(strncasecmp(buf, "Subject:", strlen("Subject:")) == 0) state->message_state = MSG_SUBJECT; + else if(strncasecmp(buf, "Recipient:", strlen("Recipient:")) == 0) state->message_state = MSG_RECIPIENT; else if(strncasecmp(buf, "Date:", strlen("Date:")) == 0 && sdata->sent == 0) sdata->sent = parse_date_header(buf); if(state->message_state == MSG_MESSAGE_ID && state->message_id[0] == 0){ @@ -302,6 +314,11 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int } + if(state->message_state == MSG_RECIPIENT){ + p = strstr(buf, "Expanded:"); + if(p) *p = '\0'; + } + if(state->is_1st_header == 1 && state->message_state == MSG_REFERENCES){ if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11); else parse_reference(state, buf); @@ -431,7 +448,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int /* skip irrelevant headers */ - if(state->is_header == 1 && state->message_state != MSG_FROM && state->message_state != MSG_TO && state->message_state != MSG_CC) return 0; + if(state->is_header == 1 && state->message_state != MSG_FROM && state->message_state != MSG_TO && state->message_state != MSG_CC && state->message_state != MSG_RECIPIENT) return 0; /* don't process body if it's not a text or html part */ @@ -506,7 +523,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int } } } - else if((state->message_state == MSG_TO || state->message_state == MSG_CC) && state->is_1st_header == 1 && state->tolen < MAXBUFSIZE-len-1){ + else if((state->message_state == MSG_TO || state->message_state == MSG_CC || state->message_state == MSG_RECIPIENT) && state->is_1st_header == 1 && state->tolen < MAXBUFSIZE-len-1){ if(is_string_on_list(state->rcpt, puf) == 0){ append_list(&(state->rcpt), puf); diff --git a/src/parser_utils.c b/src/parser_utils.c index c3c87eda..ce8635ad 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -90,6 +90,8 @@ void init_state(struct _state *state){ state->tolen = 0; state->bodylen = 0; + + state->ms_journal = 0; } @@ -507,7 +509,7 @@ void translateLine(unsigned char *p, struct _state *state){ for(; *p; p++){ - if( (state->message_state == MSG_RECEIVED || state->message_state == MSG_FROM || state->message_state == MSG_TO || state->message_state == MSG_CC) && *p == '@'){ continue; } + if( (state->message_state == MSG_RECEIVED || state->message_state == MSG_FROM || state->message_state == MSG_TO || state->message_state == MSG_CC || state->message_state == MSG_RECIPIENT) && *p == '@'){ continue; } if(state->message_state == MSG_SUBJECT && (*p == '%' || *p == '_' || *p == '&') ){ continue; }