From 9b193b1f26e9f46be1640c299d608a44da595944 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Sat, 17 Feb 2024 17:14:42 +0100 Subject: [PATCH] Fix slashguard Slashguard wasn't working since merging https://github.com/profanity-im/profanity/pull/1943. In 7eac636fc80016dbf18eea60a7d59576dd2a4925 the user input processing was moved to be in gmainloop via inp_add_watch(). Fix https://github.com/profanity-im/profanity/issues/1955 --- src/ui/inputwin.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 1b09c448..cac088cc 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -183,6 +183,19 @@ _inp_callback(GIOChannel* source, GIOCondition condition, gpointer data) ui_reset_idle_time(); if (inp_line) { + if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) { + // ignore quoted messages + if (strlen(inp_line) > 1 && inp_line[0] != '>') { + char* res = (char*)memchr(inp_line + 1, '/', 3); + if (res) { + cons_show("Your text contains a slash in the first 4 characters"); + free(inp_line); + inp_line = NULL; + return TRUE; + } + } + } + ProfWin* window = wins_get_current(); if (!cmd_process_input(window, inp_line)) @@ -242,16 +255,6 @@ inp_readline(void) } if (inp_line) { - if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) { - // ignore quoted messages - if (strlen(inp_line) > 1 && inp_line[0] != '>') { - char* res = (char*)memchr(inp_line + 1, '/', 3); - if (res) { - cons_show("Your text contains a slash in the first 4 characters"); - return NULL; - } - } - } return strdup(inp_line); } else { return NULL;