[geary/mjog/preview-regex-segfault] Fix segfault on invalid UTF-8 when generating preview



commit 7bac77df7b8d884e2bd58a838726b909df9e6da2
Author: Michael Gratton <mike vee net>
Date:   Tue Oct 22 13:07:27 2019 +1100

    Fix segfault on invalid UTF-8 when generating preview

 src/engine/rfc822/rfc822-utils.vala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 55a92061..37a967fb 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -248,7 +248,10 @@ public string to_preview_text(string? text, TextFormat format) {
         preview = Geary.HTML.html_to_text(text, false);
     }
 
-    return Geary.String.reduce_whitespace(preview);
+    // XXX really shouldn't have to call make_valid here but do so to
+    // avoid segfaults in the regex engine on invalid char data. See
+    // issue #186 for the proper fix.
+    return Geary.String.reduce_whitespace(preview.make_valid());
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]