From d78d582eaa99f63feccb08cf92399d921106867a Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Thu, 7 Mar 2024 23:22:02 +0100 Subject: [PATCH] Streamline validation in utf8decode() https://lists.suckless.org/hackers/2207/18407.html --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index ce42395..46eecbd 100644 --- a/st.c +++ b/st.c @@ -313,8 +313,8 @@ utf8decode(const char *c, Rune *u, size_t clen) } if (j < len) return 0; - *u = udecoded; - utf8validate(u, len); + *u = (!BETWEEN(udecoded, utfmin[len], utfmax[len]) || BETWEEN(udecoded, 0xD800, 0xDFFF)) + ? UTF_INVALID : udecoded; return len; }