Wietse Venema via Postfix-users: > Viktor Dukhovni via Postfix-users: > > On Fri, Oct 06, 2023 at 06:50:38PM -0400, Wietse Venema via Postfix-users > > wrote: > > > > > + } else { > > > + server->username = mystrdup(serverout); > > > + printable(server->username, '?'); > > > > I might note that when UTF8 is enabled, this does correctly leaves valid > > UTF8 characters undisturbed. > > > > However, I also took a close look at printable(), and noticed that it > > admits UTF-8 code points with outside the the Unicode range (leader byte > > up to 254), while the maximum valid UTF-8 lead byte tops out at 244 > > (0b11110100), for characters in the range U+100000?U+10FFFF. > > > > And also, the number of non-leader bytes is not validated, allowing > > for abitrarily long runs of 0b10xxxxxx octets after the leader byte. > > > > I think we can do better: > > Indeed. But we already have valid_utf8_string(), I'll see if we > can reuse more code between valid_utf8_string() and printable().
In postfix-3.9-20231008 I have factored out the UTF8 parser so that it can be reused in both valid_utf8_string() and printable(). The result is simpler code (it's easier to read if you look at the code instead of the diffs). I adopted the tests for the printable() function. The code is written for compilers that support the C99 feature to "inline" functions. If that feature is not available, then there will be some function call overhead. Wietse _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org