]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow lua_text in addition to strings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Dec 2021 16:16:56 +0000 (16:16 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Dec 2021 16:16:56 +0000 (16:16 +0000)
src/lua/lua_text.c
src/lua/lua_util.c

index d1fd87ded9a602799292d84e14d91ab0cc6b6746..f88b5c29bcfbadfdbee9ed0737da2dd6711ea374 100644 (file)
@@ -292,7 +292,7 @@ lua_check_text_or_string (lua_State * L, gint pos)
                 * Fake static lua_text, we allow to use this function multiple times
                 * by having a small array of static structures.
                 */
-               static int cur_txt_idx = 0;
+               static unsigned cur_txt_idx = 0;
                static struct rspamd_lua_text fake_text[4];
                gsize len;
                int sel_idx;
index 570a51be77a29ffc3437a5b15bdc4347db619eb6..4dd944008318683ef3828f95b1776ceb9314c3d5 100644 (file)
@@ -1366,11 +1366,12 @@ static gint
 lua_util_fold_header (lua_State *L)
 {
        LUA_TRACE_POINT;
-       const gchar *name, *value, *how, *stop_chars = NULL;
+       const gchar *how, *stop_chars = NULL;
+       struct rspamd_lua_text *name, *value;
        GString *folded;
 
-       name = luaL_checkstring (L, 1);
-       value = luaL_checkstring (L, 2);
+       name = lua_check_text_or_string (L, 1);
+       value = lua_check_text_or_string (L, 2);
 
        if (name && value) {
 
@@ -1383,20 +1384,25 @@ lua_util_fold_header (lua_State *L)
                        }
 
                        if (strcmp (how, "cr") == 0) {
-                               folded = rspamd_header_value_fold (name, value, 0,
+                               folded = rspamd_header_value_fold (name->start, name->len,
+                                               value->start, value->len,
+                                               0,
                                                RSPAMD_TASK_NEWLINES_CR, stop_chars);
                        }
                        else if (strcmp (how, "lf") == 0) {
-                               folded = rspamd_header_value_fold (name, value, 0,
+                               folded = rspamd_header_value_fold (name->start, name->len,
+                                               value->start, value->len, 0,
                                                RSPAMD_TASK_NEWLINES_LF, stop_chars);
                        }
                        else {
-                               folded = rspamd_header_value_fold (name, value, 0,
+                               folded = rspamd_header_value_fold (name->start, name->len,
+                                               value->start, value->len, 0,
                                                RSPAMD_TASK_NEWLINES_CRLF, stop_chars);
                        }
                }
                else {
-                       folded = rspamd_header_value_fold (name, value, 0,
+                       folded = rspamd_header_value_fold (name->start, name->len,
+                                       value->start, value->len, 0,
                                        RSPAMD_TASK_NEWLINES_CRLF, stop_chars);
                }