mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
guri: Correctly set an error when parsing an invalid hostname
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
1d461bc9f4
commit
95c19181ae
16
glib/guri.c
16
glib/guri.c
@ -604,9 +604,21 @@ parse_host (const gchar *start,
|
||||
}
|
||||
|
||||
if (g_hostname_is_non_ascii (decoded))
|
||||
host = g_hostname_to_ascii (decoded);
|
||||
{
|
||||
host = g_hostname_to_ascii (decoded);
|
||||
if (host == NULL)
|
||||
{
|
||||
g_free (decoded);
|
||||
g_set_error (error, G_URI_ERROR, G_URI_ERROR_BAD_HOST,
|
||||
_("Illegal internationalized hostname ‘%.*s’ in URI"),
|
||||
(gint) length, start);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
host = g_steal_pointer (&decoded);
|
||||
{
|
||||
host = g_steal_pointer (&decoded);
|
||||
}
|
||||
|
||||
ok:
|
||||
if (out)
|
||||
|
@ -758,6 +758,10 @@ static const UriAbsoluteTest absolute_tests[] = {
|
||||
{ NULL, NULL, NULL, -1, NULL, NULL, NULL } },
|
||||
{ "http://[fe80::dead:beef%25em1%00]/", G_URI_FLAGS_NONE, FALSE, G_URI_ERROR_BAD_HOST,
|
||||
{ NULL, NULL, NULL, -1, NULL, NULL, NULL } },
|
||||
|
||||
/* Invalid IDN hostname */
|
||||
{ "http://xn--mixed-\xc3\xbcp/", G_URI_FLAGS_NONE, FALSE, G_URI_ERROR_BAD_HOST,
|
||||
{ NULL, NULL, NULL, -1, NULL, NULL, NULL } },
|
||||
};
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user