From 7d9ec52bf2b6f6d280f6120c7a56f6746e1b16b1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 14 Jul 2015 13:48:39 +0100 Subject: [PATCH] Only allow 'sane' register names Fixes #316 --- src/normal.cc | 4 ++-- src/register_manager.cc | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 86d3d416d..4c54ea051 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 27ca47bdb..7c1747316 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());