commit 7df2c18: [Minor] Add has_symbol function to rspamd expressions
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jun 18 11:56:10 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-06-18 12:50:45 +0100
URL: https://github.com/rspamd/rspamd/commit/7df2c1887ef78a03bab5f54efea054103b8c3755
[Minor] Add has_symbol function to rspamd expressions
---
src/libmime/mime_expressions.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
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
More information about the Commits
mailing list