mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-25 10:42:07 +03:00
rcfile: disallow 'bind' and 'unbind' in an included file
Included files are meant to contain only syntax definitions; they may not set or unset options, nor rebind keys, nor include other files. This fixes https://savannah.gnu.org/bugs/?47391.
This commit is contained in:
parent
30f3c53305
commit
9330aa60a5
37
src/rcfile.c
37
src/rcfile.c
@ -967,34 +967,9 @@ void parse_rcfile(FILE *rcstream
|
||||
keyword = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Try to parse the keyword. */
|
||||
if (strcasecmp(keyword, "set") == 0) {
|
||||
#ifndef DISABLE_COLOR
|
||||
if (syntax_only)
|
||||
rcfile_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else
|
||||
#endif
|
||||
set = 1;
|
||||
} else if (strcasecmp(keyword, "unset") == 0) {
|
||||
#ifndef DISABLE_COLOR
|
||||
if (syntax_only)
|
||||
rcfile_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else
|
||||
#endif
|
||||
set = -1;
|
||||
}
|
||||
#ifndef DISABLE_COLOR
|
||||
else if (strcasecmp(keyword, "include") == 0) {
|
||||
if (syntax_only)
|
||||
rcfile_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else
|
||||
parse_includes(ptr);
|
||||
} else if (strcasecmp(keyword, "syntax") == 0) {
|
||||
if (strcasecmp(keyword, "syntax") == 0) {
|
||||
if (opensyntax && lastcolor == NULL)
|
||||
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
||||
live_syntax->name);
|
||||
@ -1020,7 +995,17 @@ void parse_rcfile(FILE *rcstream
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
else if (syntax_only)
|
||||
rcfile_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else if (strcasecmp(keyword, "include") == 0)
|
||||
parse_includes(ptr);
|
||||
else
|
||||
#endif /* !DISABLE_COLOR */
|
||||
if (strcasecmp(keyword, "set") == 0)
|
||||
set = 1;
|
||||
else if (strcasecmp(keyword, "unset") == 0)
|
||||
set = -1;
|
||||
else if (strcasecmp(keyword, "bind") == 0)
|
||||
parse_binding(ptr, TRUE);
|
||||
else if (strcasecmp(keyword, "unbind") == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user