[Spice-devel] [spice-gtk] Ensure '\0' is not part of text clipboard data

Christophe Fergeau cfergeau at redhat.com
Tue Aug 12 07:26:17 PDT 2014


On Windows, with some versions of gtk+, GtkSelectionData::length
will include the final '\0'.
When a string with this trailing '\0' is pasted in some linux
applications, it will be pasted as <NIL> or as an invisible character,
which is unwanted.

This commit ensures the length we send to the agent does not
include any trailing '\0'.

https://bugzilla.redhat.com/show_bug.cgi?id=1090122
---
 gtk/spice-gtk-session.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index db5c53c..84a83a2 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -890,6 +890,15 @@ static void clipboard_received_cb(GtkClipboard *clipboard,
         }
 
         len = strlen(conv);
+    } else {
+        /* On Windows, with some versions of gtk+, GtkSelectionData::length
+         * will include the final '\0'. When a string with this trailing '\0'
+         * is pasted in some linux applications, it will be pasted as <NIL> or
+         * as an invisible character, which is unwanted. Ensure the length we
+         * send to the agent does not include any trailing '\0'
+         * This is gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=734670
+         */
+        len = strlen((const char *)data);
     }
 
     spice_main_clipboard_selection_notify(s->main, selection, type,
-- 
1.9.3



More information about the Spice-devel mailing list