mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 18:20:12 +01:00
improved the search feature
Change-Id: Ia714ffade38edc9dd19b70ba37f996e6705ce057 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
12ea64c90b
commit
961ae7afee
@ -38,6 +38,7 @@
|
|||||||
#define QUEUE_ID_LEN 16
|
#define QUEUE_ID_LEN 16
|
||||||
#define IPLEN 16+1
|
#define IPLEN 16+1
|
||||||
#define KEYLEN 56
|
#define KEYLEN 56
|
||||||
|
#define MIN_EMAIL_ADDRESS_LEN 9
|
||||||
|
|
||||||
#define CRLF "\n"
|
#define CRLF "\n"
|
||||||
|
|
||||||
|
12
src/parser.c
12
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);
|
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){
|
if(q && strlen(q) > 5){
|
||||||
memcpy(&(state->b_from_domain), q+1, strlen(q+1)-1);
|
memcpy(&(state->b_from_domain), q+1, strlen(q+1)-1);
|
||||||
if(strstr(sdata->mailfrom, "<>")){
|
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);
|
memcpy(&(state->b_to[state->tolen]), puf, len);
|
||||||
state->tolen += 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;
|
if(is_email_address_on_my_domains(puf, data) == 1) sdata->internal_recipient = 1;
|
||||||
else sdata->external_recipient = 1;
|
else sdata->external_recipient = 1;
|
||||||
|
|
||||||
//q = strchr(puf, '@');
|
|
||||||
if(q){
|
if(q){
|
||||||
if(findnode(state->rcpt_domain, q+1) == NULL){
|
if(findnode(state->rcpt_domain, q+1) == NULL){
|
||||||
addnode(state->rcpt_domain, q+1);
|
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){
|
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);
|
memcpy(&(state->b_body[state->bodylen]), puf, len);
|
||||||
state->bodylen += len;
|
state->bodylen += len;
|
||||||
}
|
}
|
||||||
@ -783,4 +788,3 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,8 +623,6 @@ void translateLine(unsigned char *p, struct parser_state *state){
|
|||||||
if(url == 1) url = 0;
|
if(url == 1) url = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*p == '@') *p = 'X';
|
|
||||||
|
|
||||||
if(delimiter_characters[(unsigned int)*p] != ' ') *p = ' ';
|
if(delimiter_characters[(unsigned int)*p] != ' ') *p = ' ';
|
||||||
/* we MUSTN'T convert it to lowercase in the 'else' case, because it breaks utf-8 encoding! */
|
/* we MUSTN'T convert it to lowercase in the 'else' case, because it breaks utf-8 encoding! */
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ static char delimiter_characters[] = {
|
|||||||
'x',' ','"','#', ' ','%','&','x', '(',')','*','+', ',',' ',' ','/',
|
'x',' ','"','#', ' ','%','&','x', '(',')','*','+', ',',' ',' ','/',
|
||||||
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',':',';', '<','=','>','?',
|
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',':',';', '<','=','>','?',
|
||||||
|
|
||||||
'@',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ',
|
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ',
|
||||||
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','[', '\\',']','^','_',
|
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','[', '\\',']','^','_',
|
||||||
'`',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ',
|
'`',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ',
|
||||||
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','{', '|','}','~','x',
|
' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ','{', '|','}','~','x',
|
||||||
|
@ -147,20 +147,10 @@ class ControllerSearchHelper extends Controller {
|
|||||||
if($from == '') { $from = "@from"; }
|
if($from == '') { $from = "@from"; }
|
||||||
$from .= " $v";
|
$from .= " $v";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if($prev_token_is_email == 1) {
|
|
||||||
$prev_token_is_email = 0;
|
|
||||||
$from .= " $v";
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$match .= ' ' . $v;
|
$match .= ' ' . $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($match && $match != ' ' . $this->data['text_enter_search_terms']) {
|
|
||||||
$match = "@(subject,body) $match";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($from) { $match = $from . ' ' . $match; }
|
if($from) { $match = $from . ' ' . $match; }
|
||||||
|
Loading…
Reference in New Issue
Block a user