summaryrefslogtreecommitdiffstats
path: root/src/plugins/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-06-11 19:51:24 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-06-11 19:51:24 +0400
commitc9d11a65b5c801a27f154091aebe86cbd08fd319 (patch)
treee7d2c6ad3b95977cd1536ffaaba3b4c02cdf127c /src/plugins/regexp.c
parent58f19b06569c3ef46949874e2c3d5bb62ec54fc2 (diff)
downloadrspamd-c9d11a65b5c801a27f154091aebe86cbd08fd319.tar.gz
rspamd-c9d11a65b5c801a27f154091aebe86cbd08fd319.zip
* Add function "raw_header_exists" for finding headers that are not parsed by gmime (Mime-Version for example)
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r--src/plugins/regexp.c23
1 files changed, 23 insertions, 0 deletions
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;
+}