inet-address: Ignore windows specific failure

In this case getaddrinfo on Windows succeeds at parsing something that fails on Linux.
This commit is contained in:
Patrick Griffis
2025-07-07 12:55:11 -05:00
parent 7e85ae9d5f
commit e419c1e10d
2 changed files with 8 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ test_parse (void)
addr = g_inet_address_new_from_string ("204.152.189.116");
g_assert (addr != NULL);
g_object_unref (addr);
#ifndef G_OS_WIN32
#ifndef G_OS_WIN32 /* getaddrinfo on Windows does not support scope-id */
addr = g_inet_address_new_from_string ("::1%0");
g_assert (addr != NULL);
g_object_unref (addr);
@@ -65,10 +65,12 @@ test_parse (void)
g_assert (addr == NULL);
addr = g_inet_address_new_from_string ("[2001:1:2:3:4:5:6:7");
g_assert (addr == NULL);
#ifndef G_OS_WIN32 /* getaddrinfo on Windows is more forgiving about format and accepts these strings */
addr = g_inet_address_new_from_string ("[2001:1:2:3:4:5:6:7]");
g_assert (addr == NULL);
addr = g_inet_address_new_from_string ("[2001:1:2:3:4:5:6:7]:80");
g_assert (addr == NULL);
#endif
addr = g_inet_address_new_from_string ("0:1:2:3:4:5:6:7:8:9");
g_assert (addr == NULL);
addr = g_inet_address_new_from_string ("::FFFFFFF");

View File

@@ -176,8 +176,13 @@ static ResolveTest address_tests[] = {
* (just) IP addresses.
*/
{ "192.168.1.2:80", TRUE, FALSE, FALSE },
#ifndef G_OS_WIN32 /* getaddrinfo on Windows is more forgiving about format and accepts these strings */
{ "[fe80::42]", TRUE, FALSE, FALSE },
{ "[fe80::42]:80", TRUE, FALSE, FALSE },
#else
{ "[fe80::42]", TRUE, TRUE, FALSE },
{ "[fe80::42]:80", TRUE, TRUE, FALSE },
#endif
/* These should not be considered IP addresses by anyone. */
{ "192.168.258", FALSE, FALSE, FALSE },