mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
gnetworkaddress: allow IPv6 scope ids in URIs
GNetworkAddress was allowing IPv6 scope ids in g_network_address_new() / g_network_address_parse(), but not in g_network_address_parse_uri(). Fix that. Part of https://bugzilla.gnome.org/show_bug.cgi?id=669724
This commit is contained in:
@@ -235,60 +235,6 @@ test_socket_address (void)
|
||||
g_object_unref (saddr);
|
||||
}
|
||||
|
||||
static void
|
||||
test_scope_id (void)
|
||||
{
|
||||
GSocketConnectable *addr;
|
||||
GSocketAddressEnumerator *addr_enum;
|
||||
GSocketAddress *saddr;
|
||||
GInetSocketAddress *isaddr;
|
||||
GInetAddress *iaddr;
|
||||
char *str, *tostring;
|
||||
GError *error = NULL;
|
||||
int index;
|
||||
#ifdef HAVE_IF_INDEXTONAME
|
||||
char ifname[IF_NAMESIZE] = { 0 };
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IF_INDEXTONAME
|
||||
for (index = 1; index < 255; index++) {
|
||||
if (if_indextoname (1, ifname))
|
||||
break;
|
||||
}
|
||||
g_assert_cmpstr (ifname, !=, "");
|
||||
str = g_strdup_printf ("fe80::42%%%s", ifname);
|
||||
#else
|
||||
index = 1;
|
||||
str = g_strdup ("fe80::42%1");
|
||||
#endif
|
||||
|
||||
addr = g_network_address_new (str, 99);
|
||||
addr_enum = g_socket_connectable_enumerate (addr);
|
||||
saddr = g_socket_address_enumerator_next (addr_enum, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert (saddr != NULL);
|
||||
g_assert (G_IS_INET_SOCKET_ADDRESS (saddr));
|
||||
|
||||
isaddr = G_INET_SOCKET_ADDRESS (saddr);
|
||||
g_assert_cmpint (g_inet_socket_address_get_scope_id (isaddr), ==, index);
|
||||
g_assert_cmpint (g_inet_socket_address_get_port (isaddr), ==, 99);
|
||||
|
||||
iaddr = g_inet_socket_address_get_address (isaddr);
|
||||
tostring = g_inet_address_to_string (iaddr);
|
||||
g_assert_cmpstr (tostring, ==, "fe80::42");
|
||||
g_free (tostring);
|
||||
|
||||
g_object_unref (saddr);
|
||||
saddr = g_socket_address_enumerator_next (addr_enum, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (saddr == NULL);
|
||||
|
||||
g_object_unref (addr_enum);
|
||||
g_object_unref (addr);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mask_parse (void)
|
||||
{
|
||||
@@ -422,7 +368,6 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/inet-address/bytes", test_bytes);
|
||||
g_test_add_func ("/inet-address/property", test_property);
|
||||
g_test_add_func ("/socket-address/basic", test_socket_address);
|
||||
g_test_add_func ("/socket-address/scope-id", test_scope_id);
|
||||
g_test_add_func ("/address-mask/parse", test_mask_parse);
|
||||
g_test_add_func ("/address-mask/property", test_mask_property);
|
||||
g_test_add_func ("/address-mask/equal", test_mask_equal);
|
||||
|
Reference in New Issue
Block a user