Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noVNC clipboard resync on newline representation mismatch causing issues with GTK applications #3839

Open
mw-a opened this issue Oct 1, 2024 · 1 comment
Labels
bug Existing functionality not working as expected
Milestone

Comments

@mw-a
Copy link

mw-a commented Oct 1, 2024

I had users complaining about being unable to copy'n'paste multiple files in XFCE's Thunar file manager in OOD Linux interactive desktop sessions.

GTK applications seem to remember names of files to copy separated by newlines and won't accept them back on paste separated by carriage return and newline.

The issue seems to be due to automatic noVNC clipboard sync changing newline (\n) to carriage return+newline (\r\n) (at least on Windows clients). On the next click on the noVNC canvas that is synced back verbatim to the remote server. The check at

if (clipboardText !== text) {
doesn't catch it because technically it differs in the additional carrage returns inserted by the client.

Conversely copy'n'pasting multiple files in Thunar works when not placing any additional mouse clicks between copying and inserting, be it Ctrl+c and Ctrl+v or using the context menu. If there are any other clicks inbetween, Thunar's Paste option will be deactivated in the context menu.

This is with Microsoft Edge 129.0.2792.65 and Google Chrome 129.0.6668.71 on Windows 10 and OOD 3.1.4. Firefox is not affected as it does not automatically sync the clipboard.

My workaround for now consist of this bit of code which basically prevents the return sync if contents only differ in newline representation which solves the issue for me:

--- ui.js.orig  2024-10-01 11:40:23.448666003 +0000
+++ ui.js       2024-10-01 12:07:58.413650826 +0000
@@ -955,7 +955,8 @@
             .then(() => navigator.clipboard.readText())
             .then((clipboardText) => {
                 const text = document.getElementById('noVNC_clipboard_text').value;
-                if (clipboardText !== text) {
+                const nlClipboardText = clipboardText.replace(/\r\n/g, "\n");
+                if (clipboardText !== text && nlClipboardText !== text) {
                     document.getElementById('noVNC_clipboard_text').value = clipboardText;
                     UI.clipboardSend();
                 }

Would this be considered a valid solution to the problem? If so, I can certainly turn it into a PR.

What might a better solution look like?

@osc-bot osc-bot added this to the Backlog milestone Oct 1, 2024
@johrstrom
Copy link
Contributor

Hi, thanks for the issue and the possible resolution. I'll have to take a look at it in more depth, but on the surface what you have makes sense.

@johrstrom johrstrom added the bug Existing functionality not working as expected label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing functionality not working as expected
Projects
None yet
Development

No branches or pull requests

3 participants