From: Thomas Geymayer Date: Mon, 25 Aug 2014 19:49:44 +0000 (+0200) Subject: canvas::KeyboardEvent: C0/C1 control characters are not printable. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=088ce31f7cb88d0cf55b53314074a01ecd4f75eb;p=simgear.git canvas::KeyboardEvent: C0/C1 control characters are not printable. --- 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