aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-02-06 12:08:43 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-02-06 12:10:35 +0000
commit316136f428603481b78d8f6ca747c666e63fd210 (patch)
treee8945571d83836b8e592d1a30a8e6e60985ddeec
parentchangelog: smm+rmm (diff)
term: ignore attempts to set a title that contains an invalid UTF-8 sequence
Setting the title ultimately leads to a call to xdg_toplevel::set_title(). It is a protocol violation to try to set a title that contains an invalid UTF-8 sequence: The string must be encoded in UTF-8. Closes #1552
-rw-r--r--CHANGELOG.md3
-rw-r--r--terminal.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48cea306..b3255565 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -102,10 +102,13 @@
set in `[environment]`.
* Environment variables normally set by foot lost with `footclient
-E,--client-environment` ([#1568][1568]).
+* XDG toplevel protocol violation, by trying to set a title that
+ contains an invalid UTF-8 sequence ([#1552][1552]).
[1531]: https://codeberg.org/dnkl/foot/issues/1531
[1573]: https://codeberg.org/dnkl/foot/issues/1573
[1568]: https://codeberg.org/dnkl/foot/issues/1568
+[1552]: https://codeberg.org/dnkl/foot/issues/1552
### Security
diff --git a/terminal.c b/terminal.c
index ed13073e..f93e7abc 100644
--- a/terminal.c
+++ b/terminal.c
@@ -3249,6 +3249,13 @@ term_set_window_title(struct terminal *term, const char *title)
if (term->window_title != NULL && streq(term->window_title, title))
return;
+ if (mbsntoc32(NULL, title, strlen(title), 0) == (char32_t)-1) {
+ /* It's an xdg_toplevel::set_title() protocol violation to set
+ a title with an invalid UTF-8 sequence */
+ LOG_WARN("%s: title is not valid UTF-8, ignoring", title);
+ return;
+ }
+
free(term->window_title);
term->window_title = xstrdup(title);
render_refresh_title(term);