wayland: sanitize toplevel title to UTF-8

The xdg-shell protocol requires that the toplevel title is UTF-8*. Go
ahead and leverage existing mpv tools to sanitize the title. Fixes #9694

*: 0aaf12157e/stable/xdg-shell/xdg-shell.xml (L638)
This commit is contained in:
Dudemanguy 2022-01-18 19:45:27 -06:00
parent d16defac27
commit 5b16fe4134
1 changed files with 5 additions and 1 deletions

View File

@ -1490,7 +1490,11 @@ static int update_window_title(struct vo_wayland_state *wl, const char *title)
{
if (!wl->xdg_toplevel)
return VO_NOTAVAIL;
xdg_toplevel_set_title(wl->xdg_toplevel, title);
/* The xdg-shell protocol requires that the title is UTF-8. */
void *tmp = talloc_new(NULL);
struct bstr b_title = bstr_sanitize_utf8_latin1(tmp, bstr0(title));
xdg_toplevel_set_title(wl->xdg_toplevel, b_title.start);
talloc_free(tmp);
return VO_TRUE;
}