Add slashguard feature

New command `/slashguard` tries to protect against typing ` /quit` by
not allowing a slash in the first 4 characters.
This commit is contained in:
Michael Vetter
2020-03-18 18:20:05 +01:00
parent ed97e3730a
commit 3c56b289ed
10 changed files with 54 additions and 1 deletions

View File

@@ -2049,6 +2049,16 @@ cons_avatar_setting(void)
prefs_free_string(pref);
}
void
cons_slashguard_setting(void)
{
if (prefs_get_boolean(PREF_SLASH_GUARD)) {
cons_show("Slashguard (/slashguard) : ON");
} else {
cons_show("Slashguard (/slashguard) : OFF");
}
}
void
cons_show_connection_prefs(void)
{

View File

@@ -196,6 +196,13 @@ inp_readline(void)
}
if (inp_line) {
if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) {
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;

View File

@@ -320,6 +320,7 @@ void cons_color_setting(void);
void cons_os_setting(void);
void cons_correction_setting(void);
void cons_avatar_setting(void);
void cons_slashguard_setting(void);
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity);
void cons_show_contact_offline(PContact contact, char *resource, char *status);
void cons_theme_properties(void);