commit b98ea6e3f83e022771fae10b440d77f39c5206bd
parent cf889e86b97b1b82da96725945833f5be5312569
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:
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);
}