diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-04-15 14:02:54 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-04-15 14:02:54 +0000 |
| commit | 23ada09d149140b7a38d376dd4fd7e2c3da589aa (patch) | |
| tree | a5a1228e5dbc81a18b254008846f05a896286097 | |
| parent | wayland: remove has_wl_compositor_v6 (diff) | |
osc: reject notifications with invalid UTF-8 strings
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | osc.c | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 175403dc..0f3a0179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,10 @@ ## Unreleased ### Added ### Changed + +* Notifications with invalid UTF-8 strings are now ignored. + + ### Deprecated ### Removed ### Fixed @@ -524,6 +524,19 @@ osc_notify(struct terminal *term, char *string) const char *title = strtok_r(string, ";", &ctx); const char *msg = strtok_r(NULL, "\x00", &ctx); + if (title == NULL) + return; + + if (mbsntoc32(NULL, title, strlen(title), 0) == (char32_t)-1) { + LOG_WARN("%s: notification title is not valid UTF-8, ignoring", title); + return; + } + + if (msg != NULL && mbsntoc32(NULL, msg, strlen(msg), 0) == (char32_t)-1) { + LOG_WARN("%s: notification message is not valid UTF-8, ignoring", msg); + return; + } + notify_notify(term, title, msg != NULL ? msg : ""); } |
