]> source.dussan.org Git - rspamd.git/commitdiff
* Add function "raw_header_exists" for finding headers that are not parsed by gmime...
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 11 Jun 2009 15:51:24 +0000 (19:51 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 11 Jun 2009 15:51:24 +0000 (19:51 +0400)
CMakeLists.txt
src/expressions.c
src/plugins/regexp.c

index c41477181b7838589a18dd98be7aed7fe78dd92c..88b649a4bbd98c8f6265142ab5cce457b23e3b86 100644 (file)
@@ -7,7 +7,7 @@ PROJECT(rspamd C)
 
 SET(RSPAMD_VERSION_MAJOR 0)
 SET(RSPAMD_VERSION_MINOR 1)
-SET(RSPAMD_VERSION_PATCH 6)
+SET(RSPAMD_VERSION_PATCH 7)
 
 SET(RSPAMD_VERSION         "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
 SET(RSPAMD_MASTER_SITE_URL "http://cebka.pp.ru/hg/rspamd")
index 05bc12e88716c013be36deccf7666c86e86abe07..eecf6898604abcbd7a7955381aca57da53d557a5 100644 (file)
@@ -845,7 +845,6 @@ rspamd_header_exists (struct worker_task *task, GList *args)
 {
        struct expression_argument *arg;
        GList *headerlist;
-       char *c;
 
        if (args == NULL || task == NULL) {
                return FALSE;
@@ -862,13 +861,6 @@ rspamd_header_exists (struct worker_task *task, GList *args)
                g_list_free (headerlist);
                return TRUE;
        }
-       else {
-               /* Also check in raw headers */
-               if ((c = strstr (task->raw_headers, (char *)arg->data)) != NULL && 
-                       (c == task->raw_headers || *(c - 1) == '\n')) {
-                       return TRUE;
-               }
-       }
        return FALSE;
 }
 
index fbe36f29129d97fb0f2dc85e370a3bfaab69c390..7095c3041e2f39197ff493a50d2687dfae1fd8d6 100644 (file)
@@ -68,6 +68,7 @@ static struct regexp_ctx *regexp_module_ctx = NULL;
 
 static int regexp_common_filter (struct worker_task *task);
 static gboolean rspamd_regexp_match_number (struct worker_task *task, GList *args);
+static gboolean rspamd_raw_header_exists (struct worker_task *task, GList *args);
 
 int
 regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
@@ -84,6 +85,7 @@ regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
 
        *ctx = (struct module_ctx *)regexp_module_ctx;
        register_expression_function ("regexp_match_number", rspamd_regexp_match_number);
+       register_expression_function ("raw_header_exists", rspamd_raw_header_exists);
        
        return 0;
 }
@@ -662,3 +664,24 @@ rspamd_regexp_match_number (struct worker_task *task, GList *args)
 
        return res >= param_count;
 }
+
+static gboolean 
+rspamd_raw_header_exists (struct worker_task *task, GList *args)
+{
+       struct expression_argument *arg;
+
+       if (args == NULL || task == NULL) {
+               return FALSE;
+       }
+
+       arg = get_function_arg (args->data, task, TRUE);
+       if (!arg || arg->type == EXPRESSION_ARGUMENT_BOOL) {
+               msg_warn ("rspamd_raw_header_exists: invalid argument to function is passed");
+               return FALSE;
+       }
+       if (find_raw_header_pos (task->raw_headers, (char *)arg->data) == NULL) {
+               return FALSE;
+       }
+
+       return TRUE;
+}