GNOME Bugzilla – Bug 765535
Not taking care of multi-byte characters when setting MetaWindow description.
Last modified: 2016-06-07 18:22:58 UTC
`get_description` method of MetaWindow sometimes fails with error "Failed to convert UTF-8 string to JS string: Invalid byte sequence in conversion input". This happens when the title of window involved has some multi-byte Unicode characters. According to my research the problem is caused while appending first 10 characters of title to description. As we are not taking care of multi-byte characters, we might end with a string that ends in the middle of a character. The code in question is following: https://github.com/GNOME/mutter/blob/master/src/core/window.c#L769 window->desc = g_strdup_printf ("0x%lx (%.10s)", window->xwindow, window->title); Also at line 778.
Created attachment 329285 [details] [review] window: Don't create invalid UTF-8 window description strings printf string precision counts bytes so we may end up creating invalid UTF-8 strings here. Instead, use glib's unicode aware methods to clip the title.
Review of attachment 329285 [details] [review]: OK
Attachment 329285 [details] pushed as 8f7a36c - window: Don't create invalid UTF-8 window description strings