mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
osc: reject notifications with invalid UTF-8 strings
This commit is contained in:
parent
e753bb953b
commit
23ada09d14
2 changed files with 17 additions and 0 deletions
|
|
@ -54,6 +54,10 @@
|
|||
## Unreleased
|
||||
### Added
|
||||
### Changed
|
||||
|
||||
* Notifications with invalid UTF-8 strings are now ignored.
|
||||
|
||||
|
||||
### Deprecated
|
||||
### Removed
|
||||
### Fixed
|
||||
|
|
|
|||
13
osc.c
13
osc.c
|
|
@ -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 : "");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue