degesch: prevent playing with unknown options
This commit is contained in:
parent
a77ab689eb
commit
d41e3499c9
10
degesch.c
10
degesch.c
@ -4591,7 +4591,9 @@ config_dump_item (struct config_item_ *item, struct config_dump_data *data)
|
||||
config_item_write (item, false, &value);
|
||||
str_append_str (&line, &value);
|
||||
|
||||
if (has_default && strcmp (schema->default_, value.str))
|
||||
if (!schema)
|
||||
str_append (&line, " (unrecognized)");
|
||||
else if (has_default && strcmp (schema->default_, value.str))
|
||||
str_append_printf (&line, " (default: %s)", schema->default_);
|
||||
else if (!has_default && item->type != CONFIG_ITEM_NULL)
|
||||
str_append_printf (&line, " (default: %s)", "null");
|
||||
@ -4837,7 +4839,9 @@ handle_command_set_assign_item (struct app_context *ctx,
|
||||
hard_assert (item);
|
||||
|
||||
struct error *e = NULL;
|
||||
if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY)
|
||||
if (!item->schema)
|
||||
error_set (&e, "option not recognized");
|
||||
else if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY)
|
||||
// FIXME: it can also be null, which makes this message confusing
|
||||
error_set (&e, "not a string array");
|
||||
else if (add)
|
||||
@ -5301,7 +5305,7 @@ try_handle_command_help_option (struct app_context *ctx, const char *name)
|
||||
if (!schema)
|
||||
{
|
||||
buffer_send_error (ctx, ctx->global_buffer,
|
||||
"%s: %s", "This option has no schema", name);
|
||||
"%s: %s", "Option not recognized", name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user