aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-18 12:50:45 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-18 12:50:45 +0100
commit7df2c1887ef78a03bab5f54efea054103b8c3755 (patch)
tree864559bb658471951af5caa53cf738639885fea4 /src
parentdb44cc510d4991859d2682d4b8a18dc9a88be5cd (diff)
downloadrspamd-7df2c1887ef78a03bab5f54efea054103b8c3755.tar.gz
rspamd-7df2c1887ef78a03bab5f54efea054103b8c3755.zip
[Minor] Add has_symbol function to rspamd expressions
Diffstat (limited to 'src')
-rw-r--r--src/libmime/mime_expressions.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 7a0c27f1b..d7622376c 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -84,6 +84,9 @@ static gboolean rspamd_is_empty_body (struct rspamd_task *task,
static gboolean rspamd_has_flag_expr (struct rspamd_task *task,
GArray * args,
void *unused);
+static gboolean rspamd_has_symbol_expr (struct rspamd_task *task,
+ GArray * args,
+ void *unused);
static rspamd_expression_atom_t * rspamd_mime_expr_parse (const gchar *line, gsize len,
rspamd_mempool_t *pool, gpointer ud, GError **err);
@@ -157,6 +160,7 @@ static struct _fl {
{"has_flag", rspamd_has_flag_expr, NULL},
{"has_html_tag", rspamd_has_html_tag, NULL},
{"has_only_html_part", rspamd_has_only_html_part, NULL},
+ {"has_symbol", rspamd_has_symbol_expr, NULL},
{"header_exists", rspamd_header_exists, NULL},
{"is_empty_body", rspamd_is_empty_body, NULL},
{"is_html_balanced", rspamd_is_html_balanced, NULL},
@@ -2278,4 +2282,33 @@ rspamd_has_flag_expr (struct rspamd_task *task,
}
return result;
+}
+
+static gboolean
+rspamd_has_symbol_expr (struct rspamd_task *task,
+ GArray * args,
+ void *unused)
+{
+ struct expression_argument *sym_arg;
+ const gchar *symbol_str;
+
+ if (args == NULL) {
+ msg_warn_task ("no parameters to function");
+ return FALSE;
+ }
+
+ sym_arg = &g_array_index (args, struct expression_argument, 0);
+
+ if (sym_arg->type != EXPRESSION_ARGUMENT_NORMAL) {
+ msg_warn_task ("invalid parameter to function");
+ return FALSE;
+ }
+
+ symbol_str = (const gchar *)sym_arg->data;
+
+ if (rspamd_task_find_symbol_result (task, symbol_str)) {
+ return TRUE;
+ }
+
+ return FALSE;
} \ No newline at end of file