Xpra: Ticket #2109: HTML5 client clipboard doesn't fully support UTF-8

The HTML5 client doesn't properly support pasting UTF-8 characters from remote to local. Pasting UTF-8 characters display improper characters, for example the string "Каждый человек" display in the client as "Каждый человек" The server is running XPRA v2.4.2 on Debian Stretch and the HTML5 client has the problem with v2.4.2 and trunk. The browser used are Firefox and Chromium on Archlinux. This bug doesn't happen when pasting from remote to local or with xpra attach.

When debugging I found that the string got the bad encoding during the call "client.send_clipboard_token(unescape(encodeURIComponent(paste_data)));" line 662 in index.html.



Wed, 16 Jan 2019 20:31:45 GMT - cdrcnm: attachment set


Thu, 17 Jan 2019 07:11:16 GMT - Antoine Martin: status changed

The line:

client.send_clipboard_token(unescape(encodeURIComponent(paste_data)));

was added in r15512 for #1461.

You're saying "from remote to local" but this call is used for sending clipboard data from the browser (client) to the server - so this is confusing. Where do you copy the string from? (another browser window? a terminal? does it make any difference?) And where are you copying it into? (a terminal, a text editor?)


With "clipboard" debug enabled from the HTML5 client's connect page and -d clipboard on the server command line, I see:

I copy your string Каждый человек from this browser (native), then when I paste it (control-v) into gedit running in xpra, I see:

So it looks like that this line was meant to convert the unicode string we get from the browser into a UTF8 byte array. But there are two problems:


Thu, 17 Jan 2019 08:53:26 GMT - cdrcnm:

Sorry I made a mistake. It was from local to remote, from the client to the server. Copying from the server to my computer works properly.

The applications doesn't make any differences. I tried with a text editor, a browser window, a terminal and a Qt application, both on remote(xpra server) and local(my computer) and the result is always the same.


Thu, 17 Jan 2019 10:25:45 GMT - Antoine Martin: owner, status changed

Turns out that fixing (2) is enough: r21379 works for me.

@cdrcnm: if this works for you, please close this ticket.


Thu, 17 Jan 2019 16:06:37 GMT - cdrcnm:

It's working, but only with a server compiled from trunk. With the server in version 2.4.2 (.deb package) or 2.4.x and client up-to-date the bug is still present.

The log:

2019-01-17 15:56:40,698 clipboard_nesting_check(receiving, clipboard-token, ClientConnection(1 : Protocol(ws websocket: 172.17.0.4:14500 <- 172.16.15.10:46764)))
2019-01-17 15:56:40,699 process clipboard handler(clipboard-token)=<bound method GDKClipboardProtocolHelper._process_clipboard_token of GDKClipboardProtocolHelper>
2019-01-17 15:56:40,699 process clipboard token selection=CLIPBOARD, local clipboard name=CLIPBOARD, proxy=ClipboardProxy(CLIPBOARD)
2019-01-17 15:56:40,699 wire selection to raw, encoding=bytes, type=UTF8_STRING, format=28, len(data)=28
2019-01-17 15:56:40,699 got token, selection=CLIPBOARD, targets=[], target data={'UTF8_STRING': '\xd0\x9a\xd0\xb0\xd0\xb6\xd0\xb4\xd1\x8b\xd0\xb9 \xd1\x87\xd0\xb5\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb5\xd0\xba '}, claim=False, can-receive=True
2019-01-17 15:56:40,699 clipboard CLIPBOARD set to ''\xd0\x9a\xd0\xb0\xd0\xb6\xd0\xb4\xd1\x8b\xd0\xb9 \xd1\x87\xd0\xb5\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb5\xd0\xba ''
2019-01-17 15:56:40,699 clear_func(<gtk.Clipboard object at 0x7f171c903fa0 (GtkClipboard at 0x563b40b1e2a0)>, None) value=Каждый человек
2019-01-17 15:56:40,700 token packet without claim, not setting the token flag
2019-01-17 15:56:40,700 clipboard: CLIPBOARD owner_changed, enabled=True, can-send=True, can-receive=True, have_token=False, greedy_client=True, block_owner_change=True
2019-01-17 15:56:40,700 remove_block: CLIPBOARD
2019-01-17 15:56:40,742 get_func(<gtk.Clipboard object at 0x7f171c903fa0 (GtkClipboard at 0x563b40b1e2a0)>, <GtkSelectionData at 0x7ffc223856e0>, 0, None) value=Каждый человек
2019-01-17 15:56:40,762 get_func(<gtk.Clipboard object at 0x7f171c903fa0 (GtkClipboard at 0x563b40b1e2a0)>, <GtkSelectionData at 0x7ffc223856e0>, 0, None) value=Каждый человек

Thu, 17 Jan 2019 22:25:48 GMT - cdrcnm:

I checked the code changes and run a few tests. This fix works since this commit: r21134 so backporting it to 2.4.x require more changes.


Fri, 18 Jan 2019 05:08:49 GMT - Antoine Martin:

Please try r21383.


Fri, 18 Jan 2019 08:42:07 GMT - cdrcnm: status changed; resolution set

It's working.


Sat, 23 Jan 2021 05:42:27 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2109