x11/window-props: Convert WM_NAME and WM_CLASS to UTF-8

gjs throws exceptions on non UTF-8 strings which, in some cases, crash
gnome-shell. ICCCM string properties are defined to be Latin-1 encoded
so we can try to convert them to avoid it.

Note that _NET_WM_NAME is defined to be UTF-8 and we already validate
it in utf8_string_from_results() .

https://bugzilla.gnome.org/show_bug.cgi?id=752788
This commit is contained in:
Rui Matos 2016-03-22 20:30:43 +01:00
parent 8f7a36c53f
commit d62491f46e

View File

@ -635,7 +635,10 @@ reload_wm_name (MetaWindow *window,
if (value->type != META_PROP_VALUE_INVALID)
{
set_window_title (window, value->v.str);
g_autofree gchar *title = g_convert (value->v.str, -1,
"UTF-8", "LATIN1",
NULL, NULL, NULL);
set_window_title (window, title);
meta_verbose ("Using WM_NAME for new title of %s: \"%s\"\n",
window->desc, window->title);
@ -969,9 +972,13 @@ reload_wm_class (MetaWindow *window,
{
if (value->type != META_PROP_VALUE_INVALID)
{
meta_window_set_wm_class (window,
value->v.class_hint.res_class,
value->v.class_hint.res_name);
g_autofree gchar *res_class = g_convert (value->v.class_hint.res_class, -1,
"UTF-8", "LATIN1",
NULL, NULL, NULL);
g_autofree gchar *res_name = g_convert (value->v.class_hint.res_name, -1,
"UTF-8", "LATIN1",
NULL, NULL, NULL);
meta_window_set_wm_class (window, res_class, res_name);
}
else
{