[hackers] [dwm][patch] ISO 8859-1-only window name bugfix

From: Страхиња Радић <contact_AT_strahinja.org>
Date: Wed, 12 Jul 2023 18:48:45 +0200

Hi, recently André Desgualdo Pereira reported a bug in dwm when window names
consist only of characters in ISO 8859-1. In short, windows with such names
had their names broken at the place of ISO 8859-1-specific characters which are
not in ASCII, for example áâãéíóôúç. When the window name has other Unicode
characters, for example Cyrillic characters etc., the window name is shown
correctly, because it is encoded in UTF-8 and its WM_NAME's type as reported by
xprop is COMPOUND_TEXT (encoding field is set to 385). In the other case, it is
set to STRING and encoding field is set to 31.

I have determined that the window name is encoded in ISO 8859-1 and passed to
drw_text in drw.c as-is, when that function assumes the argument is encoded in
UTF-8. Commenting out the first part of the relevant if-test results in such
titles being shown correctly due to conversion by
XmbTextPropertyToTextList.

However, doing so results in other strings passed to gettextprop, which are
encoded in UTF-8 but with encoding field set to 31 (XA_STRING), to also be
passed to that function and converted according to current locale, resulting in
garbage being output instead of the intended text. This happens for root window
name set by slstatus, for example.

In this patch, I have commented out the existing first if-branch in
gettextprop, and introduced another which tests if the window is a root window.
This is probably not ideal, but the alternative would be some form of UTF-8
autodetection, the passed data being mislabeled as it is.



Received on Wed Jul 12 2023 - 18:48:45 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 12 2023 - 18:48:57 CEST