summaryrefslogtreecommitdiffstats
path: root/cmd-send-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2020-01-13 07:51:54 +0000
committernicm <nicm>2020-01-13 07:51:54 +0000
commit04eee2410df4a85005c9562db13a1fec93d7c2e4 (patch)
tree056d63f2e4f7d0b364fd69d3c3e821164dd2c6a8 /cmd-send-keys.c
parent381333c4a9fd521bee8a0287e648f0c6aeb96a0b (diff)
Treat plausible but invalid keys (like C-BSpace) as literal like any
other unrecognised string passed to send-keys. Reported by Anthony Sottile in GitHub issue 2049.
Diffstat (limited to 'cmd-send-keys.c')
-rw-r--r--cmd-send-keys.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index ddbab6f7..cc04a73f 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -60,6 +60,9 @@ static struct cmdq_item *
cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
struct cmdq_item *item, key_code key)
{
+ struct session *s = fs->s;
+ struct winlink *wl = fs->wl;
+ struct window_pane *wp = fs->wp;
struct window_mode_entry *wme;
struct key_table *table;
struct key_binding *bd;
@@ -68,7 +71,8 @@ cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
if (wme == NULL || wme->mode->key_table == NULL) {
if (options_get_number(fs->wp->window->options, "xterm-keys"))
key |= KEYC_XTERM;
- window_pane_key(fs->wp, item->client, fs->s, fs->wl, key, NULL);
+ if (window_pane_key(wp, item->client, s, wl, key, NULL) != 0)
+ return (NULL);
return (item);
}
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
@@ -87,6 +91,7 @@ cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
struct cmdq_item *item, struct args *args, int i)
{
const char *s = args->argv[i];
+ struct cmdq_item *new_item;
struct utf8_data *ud, *uc;
wchar_t wc;
key_code key;
@@ -104,8 +109,11 @@ cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
literal = args_has(args, 'l');
if (!literal) {
key = key_string_lookup_string(s);
- if (key != KEYC_NONE && key != KEYC_UNKNOWN)
- return (cmd_send_keys_inject_key(c, fs, item, key));
+ if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
+ new_item = cmd_send_keys_inject_key(c, fs, item, key);
+ if (new_item != NULL)
+ return (new_item);
+ }
literal = 1;
}
if (literal) {