summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2022-10-27 16:03:22 +0200
committerPierre Ossman <ossman@cendio.se>2022-10-27 16:03:22 +0200
commit6b555f1f746781e05348cdc9f1c7901dacc0114a (patch)
treeca190ab4100b5121b9fd8c90013c5fc7bf46fca6
parent0410cbc1908c460eb2d339e2d1a703ba1d07815d (diff)
downloadnovnc-6b555f1f746781e05348cdc9f1c7901dacc0114a.tar.gz
Mask unsupported clipboard characters
Add a more explicit '?' for characters that the clipboard cannot handle, instead of getting random junk.
-rw-r--r--core/rfb.js10
-rw-r--r--tests/test.rfb.js8
2 files changed, 16 insertions, 2 deletions
diff --git a/core/rfb.js b/core/rfb.js
index e6647ef..707de0f 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -492,8 +492,14 @@ export default class RFB extends EventTargetMixin {
} else {
let data = new Uint8Array(text.length);
for (let i = 0; i < text.length; i++) {
- // FIXME: text can have values outside of Latin1/Uint8
- data[i] = text.charCodeAt(i);
+ let code = text.charCodeAt(i);
+
+ /* Only ISO 8859-1 is supported */
+ if (code > 0xff) {
+ code = 0x3f; // '?'
+ }
+
+ data[i] = code;
}
RFB.messages.clientCutText(this._sock, data);
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index 432bcba..eb70386 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -433,6 +433,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
new Uint8Array([97, 98, 99]));
});
+ it('should mask unsupported characters', function () {
+ client.clipboardPasteFrom('abc€');
+
+ expect(RFB.messages.clientCutText).to.have.been.calledOnce;
+ expect(RFB.messages.clientCutText).to.have.been.calledWith(client._sock,
+ new Uint8Array([97, 98, 99, 63]));
+ });
+
it('should send an notify if extended clipboard is supported by server', function () {
// Send our capabilities
let data = [3, 0, 0, 0];