diff --git a/src/config.h b/src/config.h index a0362259..14132fb8 100644 --- a/src/config.h +++ b/src/config.h @@ -38,6 +38,7 @@ #define QUEUE_ID_LEN 16 #define IPLEN 16+1 #define KEYLEN 56 +#define MIN_EMAIL_ADDRESS_LEN 9 #define CRLF "\n" diff --git a/src/parser.c b/src/parser.c index 178ee56f..12b0976a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -710,7 +710,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata memcpy(&(state->b_from[strlen(state->b_from)]), puf, len); - if(does_it_seem_like_an_email_address(puf) == 1 && state->b_from_domain[0] == '\0' && len > 5){ + if(len >= MIN_EMAIL_ADDRESS_LEN && does_it_seem_like_an_email_address(puf) == 1 && state->b_from_domain[0] == '\0'){ if(q && strlen(q) > 5){ memcpy(&(state->b_from_domain), q+1, strlen(q+1)-1); if(strstr(sdata->mailfrom, "<>")){ @@ -752,11 +752,11 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata memcpy(&(state->b_to[state->tolen]), puf, len); state->tolen += len; - if(does_it_seem_like_an_email_address(puf) == 1){ + if(len >= MIN_EMAIL_ADDRESS_LEN && does_it_seem_like_an_email_address(puf) == 1){ + if(is_email_address_on_my_domains(puf, data) == 1) sdata->internal_recipient = 1; else sdata->external_recipient = 1; - //q = strchr(puf, '@'); if(q){ if(findnode(state->rcpt_domain, q+1) == NULL){ addnode(state->rcpt_domain, q+1); @@ -775,6 +775,11 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata } else if(state->message_state == MSG_BODY && len >= cfg->min_word_len && state->bodylen < BIGBUFSIZE-len-1){ + // 99% of email addresses are longer than 8 characters + if(len >= MIN_EMAIL_ADDRESS_LEN && does_it_seem_like_an_email_address(puf)){ + fix_email_address_for_sphinx(puf); + } + memcpy(&(state->b_body[state->bodylen]), puf, len); state->bodylen += len; } @@ -783,4 +788,3 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata return 0; } - diff --git a/src/parser_utils.c b/src/parser_utils.c index f06cb64a..71ad3b60 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -623,8 +623,6 @@ void translateLine(unsigned char *p, struct parser_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! */ diff --git a/src/trans.h b/src/trans.h index 562853fc..f5dee4bb 100644 --- a/src/trans.h +++ b/src/trans.h @@ -9,7 +9,7 @@ static char delimiter_characters[] = { 'x',' ','"','#', ' ','%','&','x', '(',')','*','+', ',',' ',' ','/', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',':',';', '<','=','>','?', - '@',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', + ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','[', '\\',']','^','_', '`',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','{', '|','}','~','x', diff --git a/webui/controller/search/helper.php b/webui/controller/search/helper.php index 352b9861..ea162c27 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -148,20 +148,10 @@ class ControllerSearchHelper extends Controller { $from .= " $v"; } else { - if($prev_token_is_email == 1) { - $prev_token_is_email = 0; - $from .= " $v"; - } - else { - $match .= ' ' . $v; - } + $match .= ' ' . $v; } } - if($match && $match != ' ' . $this->data['text_enter_search_terms']) { - $match = "@(subject,body) $match"; - } - if($from) { $match = $from . ' ' . $match; }