From 088ce31f7cb88d0cf55b53314074a01ecd4f75eb Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 25 Aug 2014 21:49:44 +0200 Subject: [PATCH] canvas::KeyboardEvent: C0/C1 control characters are not printable. --- simgear/canvas/events/KeyboardEvent.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/simgear/canvas/events/KeyboardEvent.cxx b/simgear/canvas/events/KeyboardEvent.cxx index ebe3198a..8e8f7a4b 100644 --- a/simgear/canvas/events/KeyboardEvent.cxx +++ b/simgear/canvas/events/KeyboardEvent.cxx @@ -305,10 +305,18 @@ namespace canvas if( key_name.empty() ) return false; - // Check if _name contains exactly one (UTF-8 encoded) printable character. std::string::const_iterator it = key_name.begin(); - utf8::next(it, key_name.end()); - return it == key_name.end(); + uint32_t cp = utf8::next(it, key_name.end()); + + // Check if _name contains exactly one (UTF-8 encoded) character. + if( it != key_name.end() ) + return false; + + // C0 and C1 control characters are not printable. + if( cp <= 0x1f || (0x7f <= cp && cp <= 0x9f) ) + return false; + + return true; } } // namespace canvas -- 2.39.5