-
Notifications
You must be signed in to change notification settings - Fork 18
Description
How to reproduce
- Comment out the following section of line 289 in
xtitle.cto simulate a client without the_NET_WM_NAME(EWMH) atom set, therefore relying on theWM_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 - Compile and run
xtitle -s. - 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.
Lines 299 to 304 in 6f46584
| if (title_len > strlen(CT_UTF8_BEGIN CT_UTF8_END) && | |
| memcmp(src, CT_UTF8_BEGIN, strlen(CT_UTF8_BEGIN)) == 0 && | |
| memcmp(src + title_len - strlen(CT_UTF8_END), CT_UTF8_END, strlen(CT_UTF8_END)) == 0) { | |
| src += strlen(CT_UTF8_BEGIN); | |
| title_len -= strlen(CT_UTF8_BEGIN CT_UTF8_END); | |
| } |
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"