summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-07-14 13:48:39 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-07-14 13:48:39 +0100
commit7d9ec52bf2b6f6d280f6120c7a56f6746e1b16b1 (patch)
tree30bf4d6f5f5e26c49170ffa038f400faeb5794fd /src
parentf87dbe410ff95a373e58e514c11171364352c826 (diff)
Only allow 'sane' register names
Fixes #316
Diffstat (limited to 'src')
-rw-r--r--src/normal.cc4
-rw-r--r--src/register_manager.cc4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 86d3d416..4c54ea05 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -1298,7 +1298,7 @@ void save_selections(Context& context, NormalParams)
{
on_next_key_with_autoinfo(context, KeymapMode::None,
[](Key key, Context& context) {
- if (key.modifiers != Key::Modifiers::None)
+ if (key.modifiers != Key::Modifiers::None or key == Key::Escape)
return;
const char reg = key.key;
@@ -1317,7 +1317,7 @@ void restore_selections(Context& context, NormalParams)
{
on_next_key_with_autoinfo(context, KeymapMode::None,
[](Key key, Context& context) {
- if (key.modifiers != Key::Modifiers::None)
+ if (key.modifiers != Key::Modifiers::None or key == Key::Escape)
return;
const char reg = key.key;
diff --git a/src/register_manager.cc b/src/register_manager.cc
index 27ca47bd..7c174731 100644
--- a/src/register_manager.cc
+++ b/src/register_manager.cc
@@ -74,6 +74,10 @@ Register& RegisterManager::operator[](StringView reg)
Register& RegisterManager::operator[](Codepoint c)
{
+ c = tolower(c);
+ if (c < 32 or c > 127)
+ throw runtime_error(format("invalid register name: '{}'", c));
+
auto& reg_ptr = m_registers[c];
if (not reg_ptr)
reg_ptr.reset(new StaticRegister());