xprop: quotes are not properly escaped in output of WM_NAME(STRING) as they are in _NET_WM_NAME(UTF8_STRING)
Submitted by Alain Kalker
Assigned to Xorg Project Team
Description
Found in xprop 1.2.1
Steps to reproduce:
At a VT, no X server or WM running (just to make sure nothing else is interfering):
$ cat .xinitrc
exec xterm
$ startx
In the xterm that opens, enter:
$ cd /tmp
$ mkdir 'dir with "quotes in" its name'
$ cd 'dir with "quotes in" its name'
$ xprop | grep WM_NAME
(Click on the xterm window)
Actual output:
WM_NAME(STRING) = "miki@miki-desktop:/tmp/dir with "quotes in" its name"
Expected output:
WM_NAME(STRING) = "miki@miki-desktop:/tmp/dir with \"quotes in\" its name"
As a corollary, open a terminal emulator which sets WM_NAME as well as the extended property _NET_WM_NAME:
$ vte&
In the vte window, enter:
$ xprop | grep WM_NAME
(click on the vte window)
Actual output:
WM_NAME(STRING) = "miki@miki-desktop:/tmp/dir with "quotes in" its name"
_NET_WM_NAME(UTF8_STRING) = "miki@miki-desktop:/tmp/dir with \"quotes in\" its name"
Expected output:
WM_NAME(STRING) = "miki@miki-desktop:/tmp/dir with \"quotes in\" its name"
_NET_WM_NAME(UTF8_STRING) = "miki@miki-desktop:/tmp/dir with \"quotes in\" its name"
As shown, the UTF8_STRING value has quotes properly escaped, the STRING value does not.
As an example of practical implication of this bug, it breaks the script at: https://faq.i3wm.org/question/2172/how-do-i-find-the-criteria-for-use-with-i3-config-commands-like-for_window-eg-to-force-splashscreens-and-dialogs-to-show-in-floating-mode/ which uses the output of xprop to generate window filter criteria.
Kind regards,
Alain Kalker