GUACAMOLE-352: Only attempt to type fully-composed strings. Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/fd47d1d7 Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/fd47d1d7 Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/fd47d1d7
Branch: refs/heads/master Commit: fd47d1d7efe966813be75dab4bbb7af0ee912d8f Parents: cdacd57 Author: Michael Jumper <mjum...@apache.org> Authored: Sun Dec 17 21:28:12 2017 -0800 Committer: Michael Jumper <mjum...@apache.org> Committed: Tue Jan 16 09:50:54 2018 -0800 ---------------------------------------------------------------------- .../src/main/webapp/modules/Keyboard.js | 28 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/fd47d1d7/guacamole-common-js/src/main/webapp/modules/Keyboard.js ---------------------------------------------------------------------- diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index e16d48e..4c4b1ba 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -1208,6 +1208,30 @@ Guacamole.Keyboard = function(element) { }, true); /** + * Returns whether the given string is fully composed. A string is fully + * composed if it does not end with combining characters. + * + * @private + * @param {String} str + * The string to test. + * + * @returns {Boolean} + * true of the string is fully composed, false otherwise. + */ + var isComposed = function isComposed(str) { + + // The empty string is fully composed + if (!str) + return true; + + // Test whether the last character is within the "Combining + // Diacritical Marks" Unicode block (U+0300 through U+036F) + var lastCodepoint = str.charCodeAt(str.length - 1); + return !(lastCodepoint >= 0x0300 && lastCodepoint <= 0x036F); + + }; + + /** * Handles the given "input" event, typing the data within the input text. * If the event is complete (text is provided), handling of "compositionend" * events is suspended, as such events may conflict with input events. @@ -1222,7 +1246,7 @@ Guacamole.Keyboard = function(element) { if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return; // Type all content written - if (e.data) { + if (e.data && isComposed(e.data)) { element.removeEventListener("compositionend", handleComposition, false); guac_keyboard.type(e.data); } @@ -1245,7 +1269,7 @@ Guacamole.Keyboard = function(element) { if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return; // Type all content written - if (e.data) { + if (e.data && isComposed(e.data)) { element.removeEventListener("input", handleInput, false); guac_keyboard.type(e.data); }