mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Added string length limit for setup file options
This commit is contained in:
+13
-1
@@ -3878,7 +3878,19 @@ weechat_cmd_set (t_irc_server *server, t_irc_channel *channel,
|
||||
weechat_options[last_section][last_option].default_string : _("empty"));
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
gui_printf (NULL, _(" . type string (any string)\n"));
|
||||
switch (weechat_options[last_section][last_option].max)
|
||||
{
|
||||
case 0:
|
||||
gui_printf (NULL, _(" . type string (any string)\n"));
|
||||
break;
|
||||
case 1:
|
||||
gui_printf (NULL, _(" . type: char (any char)\n"));
|
||||
break;
|
||||
default:
|
||||
gui_printf (NULL, _(" . type string (any string, limit: %d chars)\n"),
|
||||
weechat_options[last_section][last_option].max);
|
||||
break;
|
||||
}
|
||||
gui_printf (NULL, _(" . default value: '%s'\n"),
|
||||
(weechat_options[last_section][last_option].default_string) ?
|
||||
weechat_options[last_section][last_option].default_string : _("empty"));
|
||||
|
||||
+16
-2
@@ -187,8 +187,22 @@ weechat_display_config_options ()
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
weechat_iconv_fprintf (stdout, _(" . type: string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: any string\n"));
|
||||
switch (weechat_options[i][j].max)
|
||||
{
|
||||
case 0:
|
||||
weechat_iconv_fprintf (stdout, _(" . type: string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: any string\n"));
|
||||
break;
|
||||
case 1:
|
||||
weechat_iconv_fprintf (stdout, _(" . type: char\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: any char\n"));
|
||||
break;
|
||||
default:
|
||||
weechat_iconv_fprintf (stdout, _(" . type: string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"),
|
||||
weechat_options[i][j].max);
|
||||
break;
|
||||
}
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
|
||||
@@ -290,7 +290,7 @@ t_config_option weechat_options_look[] =
|
||||
"%a, %d %b %Y", NULL, NULL, &cfg_look_day_change_timestamp, config_change_noop },
|
||||
{ "look_read_marker", N_("use a marker on servers/channels to show first unread line"),
|
||||
N_("use a marker on servers/channels to show first unread line"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
OPTION_TYPE_STRING, 0, 1, 0,
|
||||
" ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker },
|
||||
{ "look_input_format", N_("format for input prompt"),
|
||||
N_("format for input prompt ('%c' is replaced by channel or server, "
|
||||
@@ -1430,6 +1430,8 @@ config_option_set_value (t_config_option *option, char *value)
|
||||
return -1;
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
if ((option->max > 0) && (utf8_strlen (value) > option->max))
|
||||
return -1;
|
||||
if (*(option->ptr_string))
|
||||
free (*(option->ptr_string));
|
||||
*(option->ptr_string) = strdup (value);
|
||||
|
||||
Reference in New Issue
Block a user