xtitle icon indicating copy to clipboard operation
xtitle copied to clipboard

Compound Text Parsing Bug

Open vimist opened this issue 5 years ago • 0 comments

How to reproduce

  1. Comment out the following section of line 289 in xtitle.c to simulate a client without the _NET_WM_NAME (EWMH) atom set, therefore relying on the WM_NAME (ICCCM) atom to provide the title: || xcb_ewmh_get_wm_name_reply(ewmh, xcb_ewmh_get_wm_name(ewmh, win), &ewmh_txt_prop, NULL) == 1
  2. Compile and run xtitle -s.
  3. Open a program with multiple UTF-8 character sequences distributed through the title. I'm using FireFox to visit https://unicode-table.com

Problem Code

The current code to parse the Compound Text assumes that the window title is one long UTF-8 string and only looks for the control sequences at the very start and end of the text. More intelligent code is required to parse this out properly.

https://github.com/baskerville/xtitle/blob/6f46584fe4ba2763438231e6cce5b180f5ca9c0e/xtitle.c#L299-L304

Example

The raw data returned from the WM_NAME property when visiting https://unicode-table.com in FireFox looks like this (I've highlighted what I believe to be the control sequences below).

1b 25 47 e2 9c 94 ef b8 8f 1b 25 40 20 1b 25 47 e2 9d a4 ef b8 8f 1b 25 40 20 1b 24 28 42 21 7a 1b 28 42 20 55 6e 69 63 6f 64 65 ae 20 43 68 61 72 61 63 74 65 72 20 54 61 62 6c 65 20 2d 20 4d 6f 7a 69 6c 6c 61 20 46 69 72 65 66 6f 78

Parsed correctly, it should evaluate to: "✔️ ❤️ ★ Unicode® Character Table - Mozilla Firefox"

vimist avatar Feb 12 '20 10:02 vimist