mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Merge pull request #321 from glyptodon/GUAC-1463
GUAC-1463: Don't trust the keydown event if it's for a printable character.
This commit is contained in:
@@ -178,8 +178,9 @@ Guacamole.Keyboard = function(element) {
|
|||||||
this.keysym = keysym_from_key_identifier(key, location)
|
this.keysym = keysym_from_key_identifier(key, location)
|
||||||
|| keysym_from_keycode(keyCode, location);
|
|| keysym_from_keycode(keyCode, location);
|
||||||
|
|
||||||
// DOM3 and keyCode are reliable sources
|
// DOM3 and keyCode are reliable sources if the corresponding key is
|
||||||
if (this.keysym)
|
// not a printable key
|
||||||
|
if (this.keysym && !isPrintable(this.keysym))
|
||||||
this.reliable = true;
|
this.reliable = true;
|
||||||
|
|
||||||
// Use legacy keyIdentifier as a last resort, if it looks sane
|
// Use legacy keyIdentifier as a last resort, if it looks sane
|
||||||
@@ -591,6 +592,25 @@ Guacamole.Keyboard = function(element) {
|
|||||||
return keysyms[location] || keysyms[0];
|
return keysyms[location] || keysyms[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given keysym corresponds to a printable character,
|
||||||
|
* false otherwise.
|
||||||
|
*
|
||||||
|
* @param {Number} keysym
|
||||||
|
* The keysym to check.
|
||||||
|
*
|
||||||
|
* @returns {Boolean}
|
||||||
|
* true if the given keysym corresponds to a printable character,
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
var isPrintable = function isPrintable(keysym) {
|
||||||
|
|
||||||
|
// Keysyms with Unicode equivalents are printable
|
||||||
|
return (keysym >= 0x00 && keysym <= 0xFF)
|
||||||
|
|| (keysym & 0xFFFF0000) === 0x01000000;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
function keysym_from_key_identifier(identifier, location, shifted) {
|
function keysym_from_key_identifier(identifier, location, shifted) {
|
||||||
|
|
||||||
if (!identifier)
|
if (!identifier)
|
||||||
|
Reference in New Issue
Block a user