Fix crash with too large clipboard data

If too much text is copied in the session, String.fromCharCode.apply()
would crash in Safari on macOS and Chrome on Linux. This commit fixes
this issue by avoiding apply() altogether. Also added test to cover this
issue.
This commit is contained in:
Alex Tanskanen
2020-02-20 16:12:35 +01:00
parent e4e6a9b9b4
commit ceb8ef4ec1
2 changed files with 37 additions and 1 deletions
+5 -1
View File
@@ -1504,7 +1504,11 @@ export default class RFB extends EventTargetMixin {
streamInflator.setInput(null);
if (textData !== null) {
textData = String.fromCharCode.apply(null, textData);
let tmpText = "";
for (let i = 0; i < textData.length; i++) {
tmpText += String.fromCharCode(textData[i]);
}
textData = tmpText;
textData = decodeUTF8(textData);
if ((textData.length > 0) && "\0" === textData.charAt(textData.length - 1)) {