diff --git a/.gitignore b/.gitignore index 9681b6a9..f8c8a37d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ xf86-qubes-common/libxf86-qubes-common.so /pipewire/pw-module-run *.dep /gui-agent/qubes-gui +/gui-agent/qubes-gui-runuser /gui-common/qubes-gui-runuser diff --git a/archlinux/PKGBUILD.in b/archlinux/PKGBUILD.in index d3b60434..06b623bf 100644 --- a/archlinux/PKGBUILD.in +++ b/archlinux/PKGBUILD.in @@ -23,6 +23,7 @@ makedepends=( libxcomposite libxt libxdamage + libunistring pixman lsb-release 'qubes-vm-gui-common>=4.3.0' @@ -57,6 +58,7 @@ package_qubes-vm-gui() { 'zenity' 'qubes-libvchan' 'python-xcffib' + 'libunistring' # Xorg dependencies are on specific ABI versions: https://www.x.org/wiki/XorgModuleABIVersions/ # These can also be verified with pacman -Qi xorg-server (Provides) # There is however a discrepancy if verifying via pkg-config --variable abi_videodrv xorg-server diff --git a/debian/control b/debian/control index 037450ba..69b1cf10 100644 --- a/debian/control +++ b/debian/control @@ -25,6 +25,7 @@ Build-Depends: qubes-gui-common (>= 4.3.0), qubesdb-dev, libltdl-dev, + libunistring-dev, Standards-Version: 4.4.0.1 Homepage: http://www.qubes-os.org/ #Vcs-Git: git://git.debian.org/collab-maint/qubes-gui-agent.git diff --git a/gui-agent/Makefile b/gui-agent/Makefile index 18bffee2..17f9fb6e 100644 --- a/gui-agent/Makefile +++ b/gui-agent/Makefile @@ -24,7 +24,8 @@ CFLAGS += -I../include/ `pkg-config --cflags vchan` -g -Wall -Wextra -Werror -fP -Wmissing-prototypes -Wstrict-prototypes -Wold-style-declaration \ -Wold-style-definition OBJS = vmside.o txrx-vchan.o error.o list.o encoding.o -LIBS = -lX11 -lXdamage -lXcomposite -lXfixes `pkg-config --libs vchan` -lqubesdb +LIBS = -lX11 -lXdamage -lXcomposite -lXfixes `pkg-config --libs vchan` -lqubesdb \ + -lunistring all: qubes-gui qubes-gui-runuser diff --git a/gui-agent/vmside.c b/gui-agent/vmside.c index dc847cde..0bb51bb9 100644 --- a/gui-agent/vmside.c +++ b/gui-agent/vmside.c @@ -53,6 +53,7 @@ #include "encoding.h" #include #include +#include "unistr.h" #include @@ -651,6 +652,27 @@ void send_wmname(Ghandles * g, XID window) if (!get_net_wmname(g, window, msg.data, sizeof(msg.data))) if (!getwmname_tochar(g, window, msg.data, sizeof(msg.data))) return; + if (strlen(msg.data) == sizeof(msg.data) - 1) { + // Window title might had been longer than output buffer. + // Trim at correct utf8 boundary and set end to U+2026 (Horizontal Ellipsis) + msg.data[sizeof(msg.data) - 4] = 0; + for (int i=0; i < 4; i++) { + uint8_t * last_byte = (uint8_t *)msg.data + sizeof(msg.data) - 5 - i; + // check for valid 1, 2, 3 or 4 byte uft8 char at the end of string + if ( + !u8_check(last_byte, 1) || + !u8_check(last_byte - 1, 2) || + !u8_check(last_byte - 2, 3) || + !u8_check(last_byte - 3, 4) + ) { + break; + } else { + // trim one invalid byte at end of string + *last_byte = 0; + } + } + strncat(msg.data, "\xE2\x80\xA6", sizeof(msg.data) - 1); + } hdr.window = window; hdr.type = MSG_WMNAME; write_message(g->vchan, hdr, msg); diff --git a/rpm_spec/gui-agent.spec.in b/rpm_spec/gui-agent.spec.in index da8dceea..d5b3b28c 100644 --- a/rpm_spec/gui-agent.spec.in +++ b/rpm_spec/gui-agent.spec.in @@ -75,6 +75,7 @@ BuildRequires: qubes-gui-common-devel >= 4.3.0 BuildRequires: qubes-db-devel BuildRequires: xen-devel BuildRequires: systemd-rpm-macros +BuildRequires: libunistring-devel %if 0%{?is_opensuse} # for directory ownership BuildRequires: xinit @@ -102,6 +103,7 @@ Requires: xev Requires: xdpyinfo Requires: xprop Requires: xrandr +Requires: libunistring Provides: qubes-gui-vm = %{version}-%{release} Obsoletes: qubes-gui-vm < 4.0.0