From 4c7bc9179b1675a362b360d7cbfa7157eb62df90 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Mon, 24 Jun 2019 18:17:49 +0300 Subject: [PATCH] src: Enforce case sensitivity when parsing function keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `parse_keys()` function is case insensitive when parsing function keys, while the `key_to_str()` function always returns a capitalized key description. When users hook on the lowercase name of a function key, e.g. `NormalKey `, and later hit that same key in normal mode, the `key_to_str()` will convert it to the uppercase description (""). This results into a hook with a lowercase regex predicate being unsuccessfully matched against an uppercase key description by the hook manager, which works on a case sensitive basis. One solution could be to uppercase all function key descriptions passed as hook filter upon declaration, but detecting that is not trivial as the filter can contain more than just the simple data, e.g. --- hook global InsertKey '<(?\w+)>' %{…} --- Another simpler solution that this commit implements is to allow only descriptions in `parse_keys()`, and hope users will know not to use the lowercase notation when declaring hooks. Fixes #2907 --- src/keys.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keys.cc b/src/keys.cc index e624767c..edbd5e0c 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -126,7 +126,7 @@ KeyList parse_keys(StringView str) result.push_back(canonicalize_ifn({ modifier, name_it->key })); else if (desc.char_length() == 1) result.push_back(canonicalize_ifn({ modifier, desc[0_char] })); - else if (to_lower(desc[0_byte]) == 'f' and desc.length() <= 3) + else if (desc[0_byte] == 'F' and desc.length() <= 3) { int val = str_to_int(desc.substr(1_byte)); if (val >= 1 and val <= 12)