From 63e3672632b2c062a0c593f56b5f1d6b46bd8786 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sat, 12 Dec 2009 01:21:06 +0100 Subject: [PATCH] Validate formatted URI, otherwise pass the original URI Apparently g_uri_unescape_string can return invalid UTF8, so until we can replace or fix it, we double check to avoid crashing in g_markup_escape_text and other places. --- midori/sokoke.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/midori/sokoke.c b/midori/sokoke.c index 823662ad..932d8e6b 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -610,6 +610,11 @@ sokoke_format_uri_for_display (const gchar* uri) if (!unescaped) return g_strdup (uri); + else if (!g_utf8_validate (unescaped, -1, NULL)) + { + g_free (unescaped); + return g_strdup (uri); + } hostname = sokoke_hostname_from_uri (unescaped, &path); decoded = g_hostname_to_unicode (hostname); @@ -629,6 +634,11 @@ sokoke_format_uri_for_display (const gchar* uri) if (!unescaped) return g_strdup (uri); + else if (!g_utf8_validate (unescaped, -1, NULL)) + { + g_free (unescaped); + return g_strdup (uri); + } if (!idna_to_unicode_8z8z (unescaped, &decoded, 0) == IDNA_SUCCESS) return unescaped;