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:
parent
e403f2259b
commit
63e3672632
1 changed files with 10 additions and 0 deletions
|
@ -610,6 +610,11 @@ sokoke_format_uri_for_display (const gchar* uri)
|
||||||
|
|
||||||
if (!unescaped)
|
if (!unescaped)
|
||||||
return g_strdup (uri);
|
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);
|
hostname = sokoke_hostname_from_uri (unescaped, &path);
|
||||||
decoded = g_hostname_to_unicode (hostname);
|
decoded = g_hostname_to_unicode (hostname);
|
||||||
|
@ -629,6 +634,11 @@ sokoke_format_uri_for_display (const gchar* uri)
|
||||||
|
|
||||||
if (!unescaped)
|
if (!unescaped)
|
||||||
return g_strdup (uri);
|
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)
|
if (!idna_to_unicode_8z8z (unescaped, &decoded, 0) == IDNA_SUCCESS)
|
||||||
return unescaped;
|
return unescaped;
|
||||||
|
|
Loading…
Reference in a new issue