Skip to content

Fail to get text from the clipboard when text is Latin-1 encoded but transfer data type is UTF8_STRING #2149

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

josediazfer
Copy link
Contributor

@josediazfer josediazfer commented May 13, 2025

It's not possible to paste text data with accented characters (CP-1252) from a Windows VNC connection to a Linux server. Pasting text into other desktop applications works just like gedit. In the code to be merged, each type is attempted (in the order UTF8_STRING, COMPOUND_TEXT, STRING) until the text can be retrieved from the clipboard.

In the gtkclipboard.c file (request_text_received_func function) of the GTK3 native library it does something similar:

static void
request_text_received_func (GtkClipboard     *clipboard,
                            GtkSelectionData *selection_data,
                            gpointer          data)
{
  RequestTextInfo *info = data;
  gchar *result = NULL;

  result = (gchar *) gtk_selection_data_get_text (selection_data);

  if (!result)
    {
      /* If we asked for UTF8 and didn't get it, try compound_text;
       * if we asked for compound_text and didn't get it, try string;
       * If we asked for anything else and didn't get it, give up.
       */
      GdkAtom target = gtk_selection_data_get_target (selection_data);

      if (target == gdk_atom_intern_static_string ("text/plain;charset=utf-8"))
        {
          gtk_clipboard_request_contents (clipboard,
                                          gdk_atom_intern_static_string ("UTF8_STRING"),
                                          request_text_received_func, info);
          return;
        }
      else if (target == gdk_atom_intern_static_string ("UTF8_STRING"))
        {
          gtk_clipboard_request_contents (clipboard,
                                          gdk_atom_intern_static_string ("COMPOUND_TEXT"),
                                          request_text_received_func, info);
          return;
        }
      else if (target == gdk_atom_intern_static_string ("COMPOUND_TEXT"))
        {
          gtk_clipboard_request_contents (clipboard,
                                          GDK_TARGET_STRING,
                                          request_text_received_func, info);
          return;
        }
    }

  info->callback (clipboard, result, info->user_data);
  g_free (info);
  g_free (result);
}

@akurtakov
Copy link
Member

I would appreciate if you split the functional change and reorganization in different PRs in order to make it easier what actually have you changed.

@josediazfer josediazfer changed the title Fail to get text from the clipboard when text is Latin-1 encoded but Fail to get text from the clipboard when text is Latin-1 encoded but transfer data type is UTF8_STRING May 13, 2025
@josediazfer
Copy link
Contributor Author

@akurtakov You're right, I just changed it so that the commit only has the functional change

@josediazfer josediazfer force-pushed the master branch 2 times, most recently from 168cf73 to b525e2e Compare May 13, 2025 21:24
@akurtakov
Copy link
Member

I wonder how can I reproduce this in native Linux environment. Would you please give some hints if you have an idea?

Copy link
Contributor

github-actions bot commented May 14, 2025

Test Results

   539 files   -  6     539 suites   - 6   29m 48s ⏱️ - 2m 39s
 4 364 tests  - 37   4 348 ✅  - 35   15 💤  - 3  1 ❌ +1 
16 691 runs   - 37  16 553 ✅  - 35  137 💤  - 3  1 ❌ +1 

For more details on these failures, see this check.

Results for commit bb39a8d. ± Comparison against base commit 8c7b933.

This pull request removes 37 tests.
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageDataForDifferentFractionalZoomsShouldBeDifferent
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageShouldHaveDimesionAsPerZoomLevel
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testByteArrayTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testFileTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testHtmlTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromCopiedImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageData
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageDataFromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testRtfTransfer
…

♻️ This comment has been updated with latest results.

@josediazfer
Copy link
Contributor Author

You can reproduce the problem by establishing a VNC connection with the Remmina client from a Linux machine against a VNC server (x11vnc) as shown below. A connection made from the Windows operating system with other VNC clients (RealVNC, TigerVNC) it also happens.

fail_accents

@akurtakov
Copy link
Member

The code looks good to me. I'm merging it as it shouldn't make a difference for the currently supported cases.

@akurtakov akurtakov merged commit de23a39 into eclipse-platform:master Jun 18, 2025
17 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants