From e809ef04415c137702a45a9335e4c3591f461b8b Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 20 Jan 2022 13:25:46 -0600 Subject: x11: sanitize window title to UTF-8 for EWMH Both _NET_WM_NAME and _NET_WM_ICON_NAME (part of Extended Window Manager Hints) require that the string is UTF-8*. mpv was not doing this and thus violating the spec. Just sanitize the title for these two atoms. Note that XA_WM_NAME and XA_WM_ICON_NAME have no such requirement so those atoms are left the same. Fixes #8812. *: https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html --- video/out/x11_common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index fe27483f0a..c3fa16f2a9 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1363,8 +1363,13 @@ static void vo_x11_update_window_title(struct vo *vo) vo_x11_set_property_string(vo, XA_WM_NAME, x11->window_title); vo_x11_set_property_string(vo, XA_WM_ICON_NAME, x11->window_title); - vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_NAME), x11->window_title); - vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_ICON_NAME), x11->window_title); + + /* _NET_WM_NAME and _NET_WM_ICON_NAME must be sanitized to UTF-8. */ + void *tmp = talloc_new(NULL); + struct bstr b_title = bstr_sanitize_utf8_latin1(tmp, bstr0(x11->window_title)); + vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_NAME), b_title.start); + vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_ICON_NAME), b_title.start); + talloc_free(tmp); } static void vo_x11_xembed_update(struct vo_x11_state *x11, int flags) -- cgit v1.2.3