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. https://bugzilla.gnome.org/show_bug.cgi?id=765535
This commit is contained in:
parent
8d7ae52565
commit
8f7a36c53f
@ -761,12 +761,18 @@ sync_client_window_mapped (MetaWindow *window)
|
|||||||
static void
|
static void
|
||||||
meta_window_update_desc (MetaWindow *window)
|
meta_window_update_desc (MetaWindow *window)
|
||||||
{
|
{
|
||||||
|
g_autofree gchar *title = NULL;
|
||||||
|
|
||||||
g_clear_pointer (&window->desc, g_free);
|
g_clear_pointer (&window->desc, g_free);
|
||||||
|
|
||||||
|
if (window->title)
|
||||||
|
title = g_utf8_substring (window->title, 0,
|
||||||
|
MIN (10, g_utf8_strlen (window->title, -1)));
|
||||||
|
|
||||||
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
{
|
{
|
||||||
if (window->title)
|
if (title)
|
||||||
window->desc = g_strdup_printf ("0x%lx (%.10s)", window->xwindow, window->title);
|
window->desc = g_strdup_printf ("0x%lx (%s)", window->xwindow, title);
|
||||||
else
|
else
|
||||||
window->desc = g_strdup_printf ("0x%lx", window->xwindow);
|
window->desc = g_strdup_printf ("0x%lx", window->xwindow);
|
||||||
}
|
}
|
||||||
@ -774,8 +780,8 @@ meta_window_update_desc (MetaWindow *window)
|
|||||||
{
|
{
|
||||||
guint64 small_stamp = window->stamp - G_GUINT64_CONSTANT(0x100000000);
|
guint64 small_stamp = window->stamp - G_GUINT64_CONSTANT(0x100000000);
|
||||||
|
|
||||||
if (window->title)
|
if (title)
|
||||||
window->desc = g_strdup_printf ("W%" G_GUINT64_FORMAT " (%.10s)", small_stamp, window->title);
|
window->desc = g_strdup_printf ("W%" G_GUINT64_FORMAT " (%s)", small_stamp, title);
|
||||||
else
|
else
|
||||||
window->desc = g_strdup_printf ("W%" G_GUINT64_FORMAT , small_stamp);
|
window->desc = g_strdup_printf ("W%" G_GUINT64_FORMAT , small_stamp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user