1
0
Fork 0

Fix slashguard

Slashguard wasn't working since merging
https://github.com/profanity-im/profanity/pull/1943.

In 7eac636fc8 the user input processing
was moved to be in gmainloop via inp_add_watch().

Fix https://github.com/profanity-im/profanity/issues/1955
This commit is contained in:
Michael Vetter 2024-02-17 17:14:42 +01:00
parent 569e37f018
commit 9b193b1f26
1 changed files with 13 additions and 10 deletions

View File

@ -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;