From: Vsevolod Stakhov Date: Mon, 9 May 2016 12:58:27 +0000 (+0100) Subject: [Fix] Try to handle multiline history in a more sane way X-Git-Tag: 1.3.0~512 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a48a0a416a64c30c8ab89b9f468b523f46b1bb9;p=thirdparty%2Frspamd.git [Fix] Try to handle multiline history in a more sane way --- diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c index 36de84c23c..c7f873df21 100644 --- a/src/rspamadm/lua_repl.c +++ b/src/rspamadm/lua_repl.c @@ -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); } }