diff --git a/etc/sphinx.conf b/etc/sphinx.conf index b0891ac..b858589 100644 --- a/etc/sphinx.conf +++ b/etc/sphinx.conf @@ -11,7 +11,7 @@ sql_pass = sphinx sql_query_pre = SET NAMES utf8 - sql_query = SELECT id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `attachments` FROM sph_index \ + sql_query = SELECT id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `attachments`, `attachment_types` FROM sph_index \ WHERE id<=( SELECT max_doc_id FROM sph_counter WHERE counter_id=1 ) sql_attr_uint = size @@ -33,7 +33,7 @@ sql_query_pre = SET NAMES utf8 sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM sph_index sql_query_post_index = DELETE FROM sph_index WHERE id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1) - sql_query = SELECT id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `attachments` FROM sph_index \ + sql_query = SELECT id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `attachments`, `attachment_types` FROM sph_index \ WHERE id <= (SELECT max_doc_id FROM sph_counter WHERE counter_id=1) sql_attr_uint = size diff --git a/src/config.h b/src/config.h index 10189e3..761559c 100644 --- a/src/config.h +++ b/src/config.h @@ -11,7 +11,7 @@ #define PROGNAME "piler" -#define VERSION "0.1.12" +#define VERSION "0.1.13" #define PROGINFO VERSION ", Janos SUTO \n\n" CONFIGURE_PARAMS "\n" diff --git a/src/parser.c b/src/parser.c index 2b986ec..8734677 100644 --- a/src/parser.c +++ b/src/parser.c @@ -398,7 +398,7 @@ if(strncasecmp(puf, "http://", 7) == 0 || strncasecmp(puf, "https://", 8) == 0) fixURL(puf); - if(state->is_header == 0 && strncmp(puf, "URL*", 4) && (puf[0] == ' ' || strlen(puf) > MAX_WORD_LEN || isHexNumber(puf)) ) continue; + if(state->is_header == 0 && strncmp(puf, "__URL__", 7) && (puf[0] == ' ' || strlen(puf) > MAX_WORD_LEN || isHexNumber(puf)) ) continue; len = strlen(puf); diff --git a/src/parser_utils.c b/src/parser_utils.c index 2c8b9a9..66d8740 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -496,7 +496,7 @@ void fix_email_address_for_sphinx(char *s){ for(; *s; s++){ - if(*s == '@' || *s == '.' || *s == '+') *s = 'X'; + if(*s == '@' || *s == '.' || *s == '+' || *s == '-' || *s == '_') *s = 'X'; } } @@ -589,7 +589,7 @@ if(q) *q = '\0'; snprintf(fixed_url, sizeof(fixed_url)-1, "__URL__%s ", p); - fix_email_address_for_sphinx(fixed_url); + fix_email_address_for_sphinx(fixed_url+7); strcpy(url, fixed_url); } diff --git a/src/rules.c b/src/rules.c index b2a8c10..6d0ef69 100644 --- a/src/rules.c +++ b/src/rules.c @@ -147,6 +147,8 @@ int i; size_t nmatch=0; + if(state->n_attachments == 0) return 1; + for(i=1; i<=state->n_attachments; i++){ if( regexec(&(rule->attachment_type), state->attachments[i].type, nmatch, NULL, 0) == 0 && diff --git a/util/db-mysql.sql b/util/db-mysql.sql index e4a859c..2f36de4 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -110,7 +110,8 @@ `attachment_type` char(128) default null, `_attachment_size` char(2) default null, `attachment_size` int default 0, - primary key (`id`) + primary key (`id`), + unique(`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`) ) ENGINE=InnoDB;