added X-MS-Journal-Report support

This commit is contained in:
SJ 2012-09-03 10:06:34 +02:00
parent 2bee3f317b
commit 287b8c0e45
3 changed files with 25 additions and 4 deletions

View File

@ -39,6 +39,7 @@
#define MSG_CONTENT_DISPOSITION 8 #define MSG_CONTENT_DISPOSITION 8
#define MSG_MESSAGE_ID 9 #define MSG_MESSAGE_ID 9
#define MSG_REFERENCES 10 #define MSG_REFERENCES 10
#define MSG_RECIPIENT 11
#define MAXHASH 8171 #define MAXHASH 8171
@ -157,6 +158,7 @@ struct _state {
int bodylen; int bodylen;
int tolen; int tolen;
char ms_journal;
}; };
@ -226,7 +228,7 @@ struct memcached_server {
struct __data { struct __data {
int folder; int folder;
char recursive_folder_names;
#ifdef HAVE_TRE #ifdef HAVE_TRE
struct rule *archiving_rules; struct rule *archiving_rules;
struct rule *retention_rules; struct rule *retention_rules;

View File

@ -162,6 +162,11 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
sdata->spam_message = 1; 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); //printf("buf: %s", buf);
if(state->message_rfc822 == 0 && (buf[0] == '\r' || buf[0] == '\n') ){ 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; if(state->is_header == 1) state->is_header = 0;
state->is_1st_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, "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, "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, "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); 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){ 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(state->is_1st_header == 1 && state->message_state == MSG_REFERENCES){
if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11); if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11);
else parse_reference(state, buf); 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 */ /* 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 */ /* 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){ if(is_string_on_list(state->rcpt, puf) == 0){
append_list(&(state->rcpt), puf); append_list(&(state->rcpt), puf);

View File

@ -90,6 +90,8 @@ void init_state(struct _state *state){
state->tolen = 0; state->tolen = 0;
state->bodylen = 0; state->bodylen = 0;
state->ms_journal = 0;
} }
@ -507,7 +509,7 @@ void translateLine(unsigned char *p, struct _state *state){
for(; *p; p++){ 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; } if(state->message_state == MSG_SUBJECT && (*p == '%' || *p == '_' || *p == '&') ){ continue; }