diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-04 16:26:45 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-04 16:26:45 +0000 |
commit | 478c1f63bd92cd88207bb5ded3e9236f35906386 (patch) | |
tree | fa140b4070730d14359fb89afafa4501fe79e295 | |
parent | 4ec67ca54be51a10a54dbb70433d06a9127ac16c (diff) | |
download | rspamd-478c1f63bd92cd88207bb5ded3e9236f35906386.tar.gz rspamd-478c1f63bd92cd88207bb5ded3e9236f35906386.zip |
Fix issues with re_cache lua API
-rw-r--r-- | src/lua/lua_config.c | 51 | ||||
-rw-r--r-- | src/lua/lua_task.c | 50 |
2 files changed, 52 insertions, 49 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index b7d095ded..5717e5588 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1569,7 +1569,7 @@ lua_config_register_regexp (lua_State *L) */ if (cfg != NULL) { if (!rspamd_lua_parse_table_arguments (L, 2, &err, - "re=*U{regexp};type=*S;header=V", + "*re=U{regexp};*type=S;header=V", &re, &type_str, &header_len, &header_str)) { msg_err_config ("cannot get parameters list: %e", err); @@ -1577,31 +1577,32 @@ lua_config_register_regexp (lua_State *L) g_error_free (err); } } - - if (strcmp (type_str, "header") == 0) { - type = RSPAMD_RE_HEADER; - } - else if (strcmp (type_str, "rawheader") == 0) { - type = RSPAMD_RE_RAWHEADER; - } - else if (strcmp (type_str, "mime") == 0) { - type = RSPAMD_RE_MIME; - } - else if (strcmp (type_str, "body") == 0) { - type = RSPAMD_RE_BODY; - } - else if (strcmp (type_str, "url") == 0) { - type = RSPAMD_RE_URL; - } - - if ((type == RSPAMD_RE_HEADER || type == RSPAMD_RE_RAWHEADER) - && header_str == NULL) { - msg_err_config ( - "header argument is mandatory for header/rawheader regexps"); - } else { - rspamd_re_cache_add (cfg->re_cache, re->re, type, - (gpointer) header_str, header_len); + if (strcmp (type_str, "header") == 0) { + type = RSPAMD_RE_HEADER; + } + else if (strcmp (type_str, "rawheader") == 0) { + type = RSPAMD_RE_RAWHEADER; + } + else if (strcmp (type_str, "mime") == 0) { + type = RSPAMD_RE_MIME; + } + else if (strcmp (type_str, "body") == 0) { + type = RSPAMD_RE_BODY; + } + else if (strcmp (type_str, "url") == 0) { + type = RSPAMD_RE_URL; + } + + if ((type == RSPAMD_RE_HEADER || type == RSPAMD_RE_RAWHEADER) + && header_str == NULL) { + msg_err_config ( + "header argument is mandatory for header/rawheader regexps"); + } + else { + rspamd_re_cache_add (cfg->re_cache, re->re, type, + (gpointer) header_str, header_len); + } } } diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 38da61b5b..037337fa8 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -2028,7 +2028,7 @@ lua_task_process_regexp (lua_State *L) */ if (task != NULL) { if (!rspamd_lua_parse_table_arguments (L, 2, &err, - "re=*U{regexp};type=*S;header=V;strong=B;multiple=B", + "*re=U{regexp};*type=S;header=V;strong=B;multiple=B", &re, &type_str, &header_len, &header_str, &strong, &multiple)) { msg_err_task ("cannot get parameters list: %e", err); @@ -2037,30 +2037,32 @@ lua_task_process_regexp (lua_State *L) g_error_free (err); } } - - if (strcmp (type_str, "header") == 0) { - type = RSPAMD_RE_HEADER; - } - else if (strcmp (type_str, "rawheader") == 0) { - type = RSPAMD_RE_RAWHEADER; - } - else if (strcmp (type_str, "mime") == 0) { - type = RSPAMD_RE_MIME; - } - else if (strcmp (type_str, "body") == 0) { - type = RSPAMD_RE_BODY; - } - else if (strcmp (type_str, "url") == 0) { - type = RSPAMD_RE_URL; - } - - if ((type == RSPAMD_RE_HEADER || type == RSPAMD_RE_RAWHEADER) - && header_str == NULL) { - msg_err_task ("header argument is mandatory for header/rawheader regexps"); - } else { - ret = rspamd_re_cache_process (task, task->re_rt, re->re, type, - (gpointer)header_str, header_len, strong, multiple); + if (strcmp (type_str, "header") == 0) { + type = RSPAMD_RE_HEADER; + } + else if (strcmp (type_str, "rawheader") == 0) { + type = RSPAMD_RE_RAWHEADER; + } + else if (strcmp (type_str, "mime") == 0) { + type = RSPAMD_RE_MIME; + } + else if (strcmp (type_str, "body") == 0) { + type = RSPAMD_RE_BODY; + } + else if (strcmp (type_str, "url") == 0) { + type = RSPAMD_RE_URL; + } + + if ((type == RSPAMD_RE_HEADER || type == RSPAMD_RE_RAWHEADER) + && header_str == NULL) { + msg_err_task ( + "header argument is mandatory for header/rawheader regexps"); + } + else { + ret = rspamd_re_cache_process (task, task->re_rt, re->re, type, + (gpointer) header_str, header_len, strong, multiple); + } } } |