[Xfce4-commits] <gigolo:master> Improve WebDav URI handling

Enrico Tröger noreply at xfce.org
Sun Apr 22 19:36:04 CEST 2012


Updating branch refs/heads/master
         to a0b7fa48913515b7e9d006b1988e079ea8ed2a88 (commit)
       from 567eadbc5873ba149fbedddf1be8e1016da87907 (commit)

commit a0b7fa48913515b7e9d006b1988e079ea8ed2a88
Author: Enrico Tröger <enrico at xfce.org>
Date:   Sun Apr 22 01:10:50 2012 +0200

    Improve WebDav URI handling
    
    We remove trailing slashes from the path of WebDav URIs and we do
    not automatically append a trailing slash when generating WebDav
    URIs.

 src/bookmark.c      |   12 +++++++++---
 tests/uri_parsing.c |    2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/bookmark.c b/src/bookmark.c
index b517845..d8c2341 100644
--- a/src/bookmark.c
+++ b/src/bookmark.c
@@ -234,7 +234,14 @@ gboolean gigolo_bookmark_parse_uri(GigoloBookmark *bookmark, const gchar *uri)
 	{
 		end++; /* skip the slash */
 
-		priv->path = g_strdup(end);
+		/* remove trailing slashes */
+		l = strlen(end);
+		while (end[l-1] == '/')
+		{
+			l--;
+		}
+
+		priv->path = g_strndup(end, l);
 	}
 
 	return TRUE;
@@ -317,7 +324,7 @@ static gchar *gigolo_bookmark_get_uri_real(GigoloBookmark *bookmark, gboolean es
 
 	domain = gigolo_bookmark_get_domain(bookmark);
 
-	result = g_strdup_printf("%s://%s%s%s%s%s%s/%s%s%s%s",
+	result = g_strdup_printf("%s://%s%s%s%s%s%s/%s%s%s",
 		priv->scheme,
 		(NZV(domain)) ? domain : "",
 		(NZV(domain)) ? ";" : "",
@@ -326,7 +333,6 @@ static gchar *gigolo_bookmark_get_uri_real(GigoloBookmark *bookmark, gboolean es
 		priv->host,
 		(port) ? port : "",
 		(NZV(priv->path)) ? priv->path : "",
-		(NZV(priv->path)) ? "/" : "",
 		(NZV(priv->share)) ? priv->share : "",
 		(NZV(priv->share)) ? "/" : "");
 
diff --git a/tests/uri_parsing.c b/tests/uri_parsing.c
index ac94e0a..eec492d 100644
--- a/tests/uri_parsing.c
+++ b/tests/uri_parsing.c
@@ -103,7 +103,7 @@ gint main(gint argc, gchar **argv)
 		{ "dav://localhost.localdomain/", "dav://localhost.localdomain/", "dav", "localhost.localdomain", NULL, NULL, 0, NULL},
 		{ "dav://localhost.localdomain", "dav://localhost.localdomain/", "dav", "localhost.localdomain", NULL, NULL, 0, NULL},
 		{ "dav://user@dav.domain.tld/owncloud/files/webdav.php", "dav://user@dav.domain.tld/owncloud/files/webdav.php", "dav", "dav.domain.tld", NULL, "owncloud/files/webdav.php", 0, "user"},
-		{ "davs://user@localhost.localdomain/path/path2/more", "davs://user@localhost.localdomain/path/path2/more", "davs", "localhost.locaaldomain", NULL, "path/path2/more", 0, "user"},
+		{ "davs://user@localhost.localdomain/path/path2/more//", "davs://user@localhost.localdomain/path/path2/more/", "davs", "localhost.locaaldomain", NULL, "path/path2/more", 0, "user"},
 		{ NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL }
 	};
 	GigoloBookmark *bm;


More information about the Xfce4-commits mailing list