mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 22:16:22 +00:00
Refactor slashguard
Fixes #2054
Fixes: 95c2199c ("Some more memory improvements")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -170,6 +170,25 @@ create_input_window(void)
|
|||||||
_inp_win_update_virtual();
|
_inp_win_update_virtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_inp_slashguard_check(void)
|
||||||
|
{
|
||||||
|
if (get_password)
|
||||||
|
return false;
|
||||||
|
/* ignore empty and quoted messages */
|
||||||
|
if (inp_line == NULL || inp_line[0] == '\0' || inp_line[0] == '>')
|
||||||
|
return false;
|
||||||
|
if (!prefs_get_boolean(PREF_SLASH_GUARD))
|
||||||
|
return false;
|
||||||
|
if (memchr(inp_line + 1, '/', 3)) {
|
||||||
|
cons_show("Your text contains a slash in the first 4 characters");
|
||||||
|
free(inp_line);
|
||||||
|
inp_line = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
inp_readline(void)
|
inp_readline(void)
|
||||||
{
|
{
|
||||||
@@ -203,17 +222,7 @@ inp_readline(void)
|
|||||||
chat_state_idle();
|
chat_state_idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inp_line) {
|
if (inp_line && !_inp_slashguard_check()) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
char* ret = inp_line;
|
char* ret = inp_line;
|
||||||
inp_line = NULL;
|
inp_line = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user