[gvfs/wip/oholy/ipv6-zoneid] client: Add support for zone identifiers in IPv6 addresses
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/ipv6-zoneid] client: Add support for zone identifiers in IPv6 addresses
- Date: Wed, 1 Jul 2020 07:46:04 +0000 (UTC)
commit 5266595595bf7cb3cf895ee04454b79aaada7c5c
Author: Ondrej Holy <oholy redhat com>
Date: Tue Jun 30 14:29:46 2020 +0200
client: Add support for zone identifiers in IPv6 addresses
The IPv6 addresses with zone identifiers are refused by GVfs currently.
THis is because of g_uri_unescape_segment failure as RFC 4007 allows bare
% sign to be used as separator. Although, RFC 6874 tries to fix that by
the %25 separator, however, at the same time, it suggests that the bare %
sign should still be accepted in user interfaces. But this would make this
too complex and lead to various problems (e.g. it would not be clear what
separator should be used for g_file_get_uri function). So I intentionally
don't plan to support what is suggested by RFC 6874 for now, which
effectively means that zone identifiers with non-ASCII chars won't be
supported. Let's skip the g_uri_unescape_segment function for IPv6 address
and also fix the gvfs_is_ipv6 function in order to accept the zone
identifiers...
Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/483
client/gvfsuriutils.c | 16 +++++++++++++++-
common/gvfsutils.c | 11 +----------
2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/client/gvfsuriutils.c b/client/gvfsuriutils.c
index 40a7afac..b7ddb6d9 100644
--- a/client/gvfsuriutils.c
+++ b/client/gvfsuriutils.c
@@ -245,7 +245,21 @@ g_vfs_decode_uri (const char *uri)
decoded->port = -1;
}
- decoded->host = g_uri_unescape_segment (host_start, host_end, NULL);
+ /* Let's use the IPv6 address without unescaping. This is needed in order
+ * to prevent g_uri_unescape_segment failures when zone identifier
+ * separated by the bare % as it is defined by RFC 4007 is used here. The
+ * zone identifier should contain just ASCII characters as per RFC 4007,
+ * so it doesn't need to be unescaped. I intentionally don't support here
+ * what is suggested by RFC 6874, which changes the separator to %25 and
+ * at the same time, it suggests that the bare % sign should still be
+ * accepted in user interfaces. Such a thing would make this too complex
+ * and lead to various problems (e.g. it would not be clear what separator
+ * should be used for g_file_get_uri function)...
+ */
+ if (*host_start == '[')
+ decoded->host = g_strndup (host_start, host_end - host_start);
+ else
+ decoded->host = g_uri_unescape_segment (host_start, host_end, NULL);
hier_part_start = authority_end;
}
diff --git a/common/gvfsutils.c b/common/gvfsutils.c
index cb994e4f..8e175d8c 100644
--- a/common/gvfsutils.c
+++ b/common/gvfsutils.c
@@ -129,18 +129,9 @@ gvfs_setup_debug_handler (void)
gboolean
gvfs_is_ipv6 (const char *host)
{
- const char *p = host;
-
g_return_val_if_fail (host != NULL, FALSE);
- if (*p != '[')
- return FALSE;
-
- while (++p)
- if (!g_ascii_isxdigit (*p) && *p != ':')
- break;
-
- if (*p != ']' || *(p + 1) != '\0')
+ if (*host != '[' || host[strlen (host) - 1] != ']')
return FALSE;
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]