]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Try to handle multiline history in a more sane way
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 May 2016 12:58:27 +0000 (13:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 May 2016 12:58:27 +0000 (13:58 +0100)
src/rspamadm/lua_repl.c

index 36de84c23cecd36330b7ed0b600b634992dc1775..c7f873df2143c6df613a6ed8b94f884bdaac44ec 100644 (file)
@@ -394,6 +394,7 @@ rspamadm_lua_run_repl (lua_State *L)
        gchar *input;
        gboolean is_multiline = FALSE;
        GString *tb;
+       guint i;
 
        for (;;) {
                if (!is_multiline) {
@@ -435,11 +436,20 @@ rspamadm_lua_run_repl (lua_State *L)
                                is_multiline = FALSE;
                                linenoiseFree (input);
                                rspamadm_exec_input (L, tb->str);
+
+                               /* Replace \n with ' ' for sanity */
+                               for (i = 0; i < tb->len; i ++) {
+                                       if (tb->str[i] == '\n') {
+                                               tb->str[i] = ' ';
+                                       }
+                               }
+
+                               linenoiseHistoryAdd (tb->str);
                                g_string_free (tb, TRUE);
                        }
                        else {
                                g_string_append (tb, input);
-                               g_string_append (tb, "\n");
+                               g_string_append (tb, " \n");
                                linenoiseFree (input);
                        }
                }