diff options
author | Dudemanguy <random342@airmail.cc> | 2022-01-20 13:25:46 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2022-01-24 15:07:00 +0000 |
commit | e809ef04415c137702a45a9335e4c3591f461b8b (patch) | |
tree | 9e5d4624ea4eb0c7806a15cab031fdd8d8e271dc /video/out/x11_common.c | |
parent | 5b16fe41346ba129b5f2bbe0288a466ffac14d0a (diff) | |
download | mpv-e809ef04415c137702a45a9335e4c3591f461b8b.tar.bz2 mpv-e809ef04415c137702a45a9335e4c3591f461b8b.tar.xz |
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
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r-- | video/out/x11_common.c | 9 |
1 files 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) |