After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 765535 - Not taking care of multi-byte characters when setting MetaWindow description.
Not taking care of multi-byte characters when setting MetaWindow description.
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2016-04-25 13:10 UTC by Abdul Moeed Ammar
Modified: 2016-06-07 18:22 UTC
See Also:
GNOME target: ---
GNOME version: 3.17/3.18


Attachments
window: Don't create invalid UTF-8 window description strings (1.84 KB, patch)
2016-06-07 14:50 UTC, Rui Matos
committed Details | Review

Description Abdul Moeed Ammar 2016-04-25 13:10:44 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.
Comment 1 Rui Matos 2016-06-07 14:50:53 UTC
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.
Comment 2 Florian Müllner 2016-06-07 15:03:30 UTC
Review of attachment 329285 [details] [review]:

OK
Comment 3 Rui Matos 2016-06-07 18:22:54 UTC
Attachment 329285 [details] pushed as 8f7a36c - window: Don't create invalid UTF-8 window description strings