Mask unsupported clipboard characters
Add a more explicit '?' for characters that the clipboard cannot handle, instead of getting random junk.
This commit is contained in:
parent
0410cbc190
commit
6b555f1f74
10
core/rfb.js
10
core/rfb.js
|
@ -492,8 +492,14 @@ export default class RFB extends EventTargetMixin {
|
||||||
} else {
|
} else {
|
||||||
let data = new Uint8Array(text.length);
|
let data = new Uint8Array(text.length);
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
// FIXME: text can have values outside of Latin1/Uint8
|
let code = text.charCodeAt(i);
|
||||||
data[i] = text.charCodeAt(i);
|
|
||||||
|
/* Only ISO 8859-1 is supported */
|
||||||
|
if (code > 0xff) {
|
||||||
|
code = 0x3f; // '?'
|
||||||
|
}
|
||||||
|
|
||||||
|
data[i] = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
RFB.messages.clientCutText(this._sock, data);
|
RFB.messages.clientCutText(this._sock, data);
|
||||||
|
|
|
@ -433,6 +433,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
new Uint8Array([97, 98, 99]));
|
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 () {
|
it('should send an notify if extended clipboard is supported by server', function () {
|
||||||
// Send our capabilities
|
// Send our capabilities
|
||||||
let data = [3, 0, 0, 0];
|
let data = [3, 0, 0, 0];
|
||||||
|
|
Loading…
Reference in New Issue