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.
This commit is contained in:
Christian Dywan 2009-12-12 01:21:06 +01:00
parent e403f2259b
commit 63e3672632

View file

@ -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;