talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 8f9fe3509cda943eb8b66f79040faf1037407c44
parent 0dc0fa955fc6d03dc19a39a7afd0c83161dd9508
Author: Jonathan Boeing <jonathan.n.boeing@gmail.com>
Date:   Mon, 29 Mar 2021 19:42:53 -0700

check if string is valid UTF-8 before collating

Diffstat:
Msrc/common/utils.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/common/utils.c b/src/common/utils.c @@ -452,6 +452,14 @@ gint subject_compare_for_sort(const gchar *s1, const gchar *s2) trim_subject_for_sort(str1); trim_subject_for_sort(str2); + if (!g_utf8_validate(str1, -1, NULL)) { + g_warning("message subject \"%s\" failed UTF-8 validation", str1); + return 0; + } else if (!g_utf8_validate(str2, -1, NULL)) { + g_warning("message subject \"%s\" failed UTF-8 validation", str2); + return 0; + } + return g_utf8_collate(str1, str2); }