]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix issues with re_cache lua API
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 4 Dec 2015 16:26:45 +0000 (16:26 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 4 Dec 2015 16:26:45 +0000 (16:26 +0000)
src/lua/lua_config.c
src/lua/lua_task.c

index b7d095deda311f867a1717e1cdbb6dd917ae2395..5717e5588df25378211652ebce514dd13c6c27a4 100644 (file)
@@ -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);
+                       }
                }
        }
 
index 38da61b5bacda0b4c81a3da4a56cf85cc35f2363..037337fa86ae3e99b0d4dffd3c4d2b13b10c33e6 100644 (file)
@@ -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);
+                       }
                }
        }