gvfs r1171 - in trunk: . client
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1171 - in trunk: . client
- Date: Wed, 23 Jan 2008 16:05:59 +0000 (GMT)
Author: hadess
Date: Wed Jan 23 16:05:59 2008
New Revision: 1171
URL: http://svn.gnome.org/viewvc/gvfs?rev=1171&view=rev
Log:
2008-01-23 Bastien Nocera <hadess hadess net>
* client/test-uri-utils.c: (main):
* client/Makefile.am: Add test program for the
functions in gvfsuriutils.c
* client/gvfsuriutils.c: (g_vfs_decode_uri):
Fix parsing of IPv6 URIs where the host is in brackets
Added:
trunk/client/test-uri-utils.c
Modified:
trunk/ChangeLog
trunk/client/Makefile.am
trunk/client/gvfsuriutils.c
Modified: trunk/client/Makefile.am
==============================================================================
--- trunk/client/Makefile.am (original)
+++ trunk/client/Makefile.am Wed Jan 23 16:05:59 2008
@@ -53,6 +53,12 @@
libgvfsdbus_la_SOURCES = $(vfssources)
libgvfsdbus_la_LIBADD = $(vfslibs)
+noinst_PROGRAMS = test-uri-utils
+
+test_uri_utils_SOURCES = test-uri-utils.c gvfsuriutils.c gvfsuriutils.h
+test_uri_utils_LDADD = $(vfslibs)
+test_uri_utils_CFLAGS = $(INCLUDES)
+
if USE_FUSE
## FUSE daemon
Modified: trunk/client/gvfsuriutils.c
==============================================================================
--- trunk/client/gvfsuriutils.c (original)
+++ trunk/client/gvfsuriutils.c Wed Jan 23 16:05:59 2008
@@ -170,7 +170,23 @@
else
host_start = authority_start;
- port_start = memchr (host_start, ':', authority_end - host_start);
+ /* We should handle hostnames in brackets, as those are used by IPv6 URIs
+ * See http://tools.ietf.org/html/rfc2732 */
+ if (*host_start == '[')
+ {
+ host_end = memchr (host_start, ']', authority_end - host_start);
+ if (host_end == NULL)
+ {
+ g_vfs_decoded_uri_free (decoded);
+ return NULL;
+ }
+ port_start = memchr (host_end, ':', authority_end - host_start);
+ }
+ else
+ {
+ port_start = memchr (host_start, ':', authority_end - host_start);
+ }
+
if (port_start)
{
host_end = port_start++;
Added: trunk/client/test-uri-utils.c
==============================================================================
--- (empty file)
+++ trunk/client/test-uri-utils.c Wed Jan 23 16:05:59 2008
@@ -0,0 +1,55 @@
+
+#include <string.h>
+
+#include "gvfsuriutils.h"
+
+
+typedef struct {
+ const char *uri;
+ const char *expected_host;
+ guint expected_port;
+} TestURIs;
+
+static TestURIs uris[] = {
+ { "https://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]:443/", "[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]", 443 },
+ { "http://test:443/", "test", 443 },
+ { "http://test/", "test", -1 }
+};
+
+int main (int argc, char **argv)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (uris); i++) {
+ GDecodedUri *decoded;
+ char *encoded;
+
+ decoded = g_vfs_decode_uri (uris[i].uri);
+ if (decoded == NULL) {
+ g_warning ("Failed to parse \"%s\"", uris[i].uri);
+ return 1;
+ }
+ if (decoded->host == NULL || strcmp (decoded->host, uris[i].expected_host) != 0) {
+ g_vfs_decoded_uri_free (decoded);
+ g_warning ("Wrong host for \"%s\"", uris[i].uri);
+ return 1;
+ }
+ if (decoded->port != uris[i].expected_port) {
+ g_vfs_decoded_uri_free (decoded);
+ g_warning ("Wrong port for \"%s\"", uris[i].uri);
+ return 1;
+ }
+ encoded = g_vfs_encode_uri (decoded, TRUE);
+ if (encoded == NULL || strcmp (encoded, uris[i].uri) != 0) {
+ g_vfs_decoded_uri_free (decoded);
+ g_free (encoded);
+ g_warning ("Failed to re-encode \"%s\"", uris[i].uri);
+ return 1;
+ }
+ g_free (encoded);
+ g_vfs_decoded_uri_free (decoded);
+ }
+
+ return 0;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]