Only allow 'sane' register names

Fixes #316
This commit is contained in:
Maxime Coste 2015-07-14 13:48:39 +01:00
parent f87dbe410f
commit 7d9ec52bf2
2 changed files with 6 additions and 2 deletions

View File

@ -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;

View File

@ -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());