Streamline validation in utf8decode()

https://lists.suckless.org/hackers/2207/18407.html
This commit is contained in:
Bakkeby 2024-03-07 23:22:02 +01:00
parent 6d5c2b3ddb
commit d78d582eaa

4
st.c
View File

@ -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;
}