1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: ignore incomplete ctrl/meta/meta2 codes in keys (issue #1875)

This commit is contained in:
Sébastien Helleu
2023-01-28 23:38:42 +01:00
parent c68c2aaa94
commit be0c04f498
2 changed files with 20 additions and 6 deletions
+1
View File
@@ -26,6 +26,7 @@ New features::
Bug fixes::
* core: ignore incomplete ctrl/meta/meta2 codes in keys
* core: fix display glitch in command errors when a wide char is set in option weechat.look.command_chars (issue #1871)
* api: readjust string size in function string_dyn_free when string is not freed
* irc: fix join of channels in "autojoin" server option on first connection to server if auto reconnection is performed (issue #1873)
+19 -6
View File
@@ -292,17 +292,20 @@ gui_key_get_internal_code (const char *key)
{
if (strncmp (key, "meta2-", 6) == 0)
{
string_dyn_concat (result, "\x01[[", -1);
if (key[6])
string_dyn_concat (result, "\x01[[", -1);
key += 6;
}
if (strncmp (key, "meta-", 5) == 0)
else if (strncmp (key, "meta-", 5) == 0)
{
string_dyn_concat (result, "\x01[", -1);
if (key[5])
string_dyn_concat (result, "\x01[", -1);
key += 5;
}
else if (strncmp (key, "ctrl-", 5) == 0)
{
string_dyn_concat (result, "\x01", -1);
if (key[5])
string_dyn_concat (result, "\x01", -1);
key += 5;
}
else if (strncmp (key, "space", 5) == 0)
@@ -651,6 +654,11 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
internal_code = gui_key_get_internal_code (key);
if (!internal_code)
return NULL;
if (!internal_code[0])
{
free (internal_code);
return NULL;
}
expanded_name = gui_key_get_expanded_name (internal_code);
if (!expanded_name)
@@ -711,7 +719,7 @@ gui_key_search (struct t_gui_key *keys, const char *key)
{
struct t_gui_key *ptr_key;
if (!key)
if (!key || !key[0])
return NULL;
for (ptr_key = keys; ptr_key; ptr_key = ptr_key->next_key)
@@ -795,7 +803,7 @@ struct t_gui_key *
gui_key_bind (struct t_gui_buffer *buffer, int context, const char *key,
const char *command)
{
if (!key || !command || (string_strcasecmp (key, "meta-") == 0))
if (!key || !command)
return NULL;
gui_key_unbind (buffer, context, key);
@@ -892,6 +900,11 @@ gui_key_unbind (struct t_gui_buffer *buffer, int context, const char *key)
internal_code = gui_key_get_internal_code (key);
if (!internal_code)
return 0;
if (!internal_code[0])
{
free (internal_code);
return 0;
}
expanded_name = gui_key_get_expanded_name (internal_code);
if (!expanded_name)