mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Merge branch 'ipv6-zoneid' into 'master'
Make g_hostname_is_ip_address() accept ipv6 zoneid See merge request GNOME/glib!1604
This commit is contained in:
commit
71d1a28afb
@ -685,6 +685,8 @@ g_hostname_is_ascii_encoded (const gchar *hostname)
|
|||||||
* Tests if @hostname is the string form of an IPv4 or IPv6 address.
|
* Tests if @hostname is the string form of an IPv4 or IPv6 address.
|
||||||
* (Eg, "192.168.0.1".)
|
* (Eg, "192.168.0.1".)
|
||||||
*
|
*
|
||||||
|
* Since 2.66, IPv6 addresses with a zone-id are accepted (RFC6874).
|
||||||
|
*
|
||||||
* Returns: %TRUE if @hostname is an IP address
|
* Returns: %TRUE if @hostname is an IP address
|
||||||
*
|
*
|
||||||
* Since: 2.22
|
* Since: 2.22
|
||||||
@ -716,7 +718,7 @@ g_hostname_is_ip_address (const gchar *hostname)
|
|||||||
|
|
||||||
nsegments = 0;
|
nsegments = 0;
|
||||||
skipped = FALSE;
|
skipped = FALSE;
|
||||||
while (*p && nsegments < 8)
|
while (*p && *p != '%' && nsegments < 8)
|
||||||
{
|
{
|
||||||
/* Each segment after the first must be preceded by a ':'.
|
/* Each segment after the first must be preceded by a ':'.
|
||||||
* (We also handle half of the "string starts with ::" case
|
* (We also handle half of the "string starts with ::" case
|
||||||
@ -760,7 +762,7 @@ g_hostname_is_ip_address (const gchar *hostname)
|
|||||||
p = end;
|
p = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !*p && (nsegments == 8 || skipped);
|
return (!*p || (p[0] == '%' && p[1])) && (nsegments == 8 || skipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_ipv4:
|
parse_ipv4:
|
||||||
|
@ -207,6 +207,11 @@ static const struct {
|
|||||||
{ "0123::123.45.67.89", TRUE },
|
{ "0123::123.45.67.89", TRUE },
|
||||||
{ "::123.45.67.89", TRUE },
|
{ "::123.45.67.89", TRUE },
|
||||||
|
|
||||||
|
/* accept zone-id from rfc6874 */
|
||||||
|
{ "0123:4567:89AB:cdef:3210:7654:ba98:FeDc%zoneid0", TRUE },
|
||||||
|
{ "fe80::dead:beef%zonÉid0%weird", TRUE },
|
||||||
|
{ "fe80::dead:beef%", FALSE },
|
||||||
|
|
||||||
/* Contain non-hex chars */
|
/* Contain non-hex chars */
|
||||||
{ "012x:4567:89AB:cdef:3210:7654:ba98:FeDc", FALSE },
|
{ "012x:4567:89AB:cdef:3210:7654:ba98:FeDc", FALSE },
|
||||||
{ "0123:45x7:89AB:cdef:3210:7654:ba98:FeDc", FALSE },
|
{ "0123:45x7:89AB:cdef:3210:7654:ba98:FeDc", FALSE },
|
||||||
@ -261,7 +266,6 @@ static const struct {
|
|||||||
{ "0123:4567:89AB:cdef:123.45.67.89", FALSE },
|
{ "0123:4567:89AB:cdef:123.45.67.89", FALSE },
|
||||||
{ "0123:4567:89AB:cdef:3210:123.45.67.89:FeDc", FALSE },
|
{ "0123:4567:89AB:cdef:3210:123.45.67.89:FeDc", FALSE },
|
||||||
|
|
||||||
|
|
||||||
/* IPv4 tests */
|
/* IPv4 tests */
|
||||||
|
|
||||||
{ "123.45.67.89", TRUE },
|
{ "123.45.67.89", TRUE },
|
||||||
|
@ -915,7 +915,12 @@ test_uri_to_string (void)
|
|||||||
tostring = g_uri_to_string (uri);
|
tostring = g_uri_to_string (uri);
|
||||||
g_assert_cmpstr (tostring, ==, "scheme://userinfo@host:1234/path?query#fragment");
|
g_assert_cmpstr (tostring, ==, "scheme://userinfo@host:1234/path?query#fragment");
|
||||||
g_free (tostring);
|
g_free (tostring);
|
||||||
|
g_uri_unref (uri);
|
||||||
|
|
||||||
|
uri = g_uri_build (G_URI_FLAGS_NONE, "scheme", NULL, "fe80::dead:beef%em1", -1, "", NULL, NULL);
|
||||||
|
tostring = g_uri_to_string (uri);
|
||||||
|
g_assert_cmpstr (tostring, ==, "scheme://[fe80::dead:beef%25em1]");
|
||||||
|
g_free (tostring);
|
||||||
g_uri_unref (uri);
|
g_uri_unref (uri);
|
||||||
|
|
||||||
uri = g_uri_build_with_user (G_URI_FLAGS_NONE, "scheme", "user", "pass", "auth", "host", 1234,
|
uri = g_uri_build_with_user (G_URI_FLAGS_NONE, "scheme", "user", "pass", "auth", "host", 1234,
|
||||||
|
Loading…
Reference in New Issue
Block a user