aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/expressions.c8
-rw-r--r--src/plugins/regexp.c23
3 files changed, 24 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c41477181..88b649a4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/src/expressions.c b/src/expressions.c
index 05bc12e88..eecf68986 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -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;
}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index fbe36f291..7095c3041 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -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;
+}