summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2016-12-01 13:02:58 +0100
committerOndrej Holy <oholy@redhat.com>2016-12-12 14:40:51 +0100
commitd8556a0db3243e9c5628307dc3f7d840d1228bd1 (patch)
treea62b1abe737432bb0afb5b79aad23cff5711e787 /client
parent2b234a0f62a858de19231c2c69fb6c1531ff4f3c (diff)
downloadgvfs-d8556a0db3243e9c5628307dc3f7d840d1228bd1.tar.gz
client: Escape ":[]" chars in host if it is not IPv6
The "[]:" chars are omitted currently when encoding uri, because they are valid for IPv6. This causes problems in some cases, e.g. output from g_file_get_uri(g_file_new_for_uri("dav+sd://foo%3Abar._webdav._tcp.local")) is "dav+sd://foo:bar._webdav._tcp.local/", which is obviously wrong. Add gvfs_is_ipv6 in order to detect IPv6 addresses and encode also "[]:" chars in other cases. Use gvfs_is_ipv6 to detect IPv6 also in some backends. https://bugzilla.gnome.org/show_bug.cgi?id=772849
Diffstat (limited to 'client')
-rw-r--r--client/gvfsuriutils.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/client/gvfsuriutils.c b/client/gvfsuriutils.c
index 58a71e19..57ad5f16 100644
--- a/client/gvfsuriutils.c
+++ b/client/gvfsuriutils.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "gvfsuriutils.h"
+#include "gvfsutils.h"
#include <string.h>
#include <stdlib.h>
@@ -264,12 +265,19 @@ g_vfs_encode_uri (GDecodedUri *decoded, gboolean allow_utf8)
G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, allow_utf8);
g_string_append_c (uri, '@');
}
-
- g_string_append_uri_escaped (uri, decoded->host,
- /* Allowed unescaped in hostname / ip address */
- G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":[]" ,
- allow_utf8);
-
+
+ if (gvfs_is_ipv6 (decoded->host))
+ {
+ g_string_append (uri, decoded->host);
+ }
+ else
+ {
+ g_string_append_uri_escaped (uri, decoded->host,
+ /* Allowed unescaped in hostname / ip address */
+ G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS,
+ allow_utf8);
+ }
+
if (decoded->port != -1)
{
g_string_append_c (uri, ':');