mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
vim-patch:8.2.3757: an overlong highlight group name is silently truncated
Problem: An overlong highlight group name is silently truncated.
Solution: Give an error if the name is too long. (closes vim/vim#9289)
f7f7aaf8aa
This commit is contained in:
@@ -115,6 +115,8 @@ static int include_none = 0; // when 1 include "nvim/None"
|
||||
static int include_default = 0; // when 1 include "nvim/default"
|
||||
static int include_link = 0; // when 2 include "nvim/link" and "clear"
|
||||
|
||||
#define MAX_SYN_NAME 200
|
||||
|
||||
/// The "term", "cterm" and "gui" arguments can be any combination of the
|
||||
/// following names, separated by commas (but no spaces!).
|
||||
static char *(hl_name_table[]) =
|
||||
@@ -7625,10 +7627,9 @@ int syn_name2id(const char *name)
|
||||
int syn_name2id_len(const char_u *name, size_t len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char name_u[201];
|
||||
char name_u[MAX_SYN_NAME + 1];
|
||||
|
||||
if (len == 0 || len > 200) {
|
||||
// ID names over 200 chars don't deserve to be found!
|
||||
if (len == 0 || len > MAX_SYN_NAME) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7686,6 +7687,10 @@ char_u *syn_id2name(int id)
|
||||
/// @return 0 for failure else the id of the group
|
||||
int syn_check_group(const char *name, int len)
|
||||
{
|
||||
if (len > MAX_SYN_NAME) {
|
||||
emsg(_(e_highlight_group_name_too_long));
|
||||
return 0;
|
||||
}
|
||||
int id = syn_name2id_len((char_u *)name, len);
|
||||
if (id == 0) { // doesn't exist yet
|
||||
return syn_add_group(vim_strnsave((char_u *)name, len));
|
||||
|
Reference in New Issue
Block a user