git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Normalise directory names when pushing to some WebDAV servers

From
GCGabriel Corona <gabriel.corona@enst-bretagne.fr>
Date
Nov 19, 2010, 00:06 UTC
Message-ID
<1290125163-31065-1-git-send-email-gabriel.corona@enst-bretagne.fr>

Fix a bug when pushing to WebDAV servers which do not use a trailing slash for collection names. The previous implementation fails to see that the requested resource "refs/" is the same resource as "refs" and loads every reference twice (once for refs/ and once for refs).

This implementation normalises every collection name by appending a trailing slash if necessary.

This can be tested with old versions of Apache (such as the WebDAV
server of GMX, Apache 2.0.63).
---
 http-push.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/http-push.c b/http-push.c
index c9bcd11..aeb37ab 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1083,6 +1083,18 @@ static void process_ls_ref(struct remote_ls_ctx *ls)
 		one_remote_ref(ls->dentry_name);
 }
 
+static void normalize_dirname(char** name) {
+	char* res;
+	int len = strlen(*name);
+	if((*name)[len-1]=='/') return;
+	res = malloc(len+2);
+	strcpy(res, *name);
+	res[len]='/';
+	res[len+1]='\0';
+	free(*name);
+	*name = res;
+}
+
 static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
 {
 	struct remote_ls_ctx *ls = (struct remote_ls_ctx *)ctx->userData;
@@ -1090,6 +1102,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
 	if (tag_closed) {
 		if (!strcmp(ctx->name, DAV_PROPFIND_RESP) && ls->dentry_name) {
 			if (ls->dentry_flags & IS_DIR) {
+				normalize_dirname(&ls->dentry_name);
 				if (ls->flags & PROCESS_DIRS) {
 					ls->userFunc(ls);
 				}
-- 
1.7.2.3
Next: Tay Ray Chuan
Message 1 of 15 in “Normalise directory names when pushing to some WebDAV servers”
  1. Normalise directory names when pushing to some WebDAV serversGabriel Corona, Nov 19, 2010
  2. Tay Ray ChuanNov 19, 2010
  3. Jonathan NiederNov 19, 2010
  4. 0/6 http (dumb): end urls with slashTay Ray Chuan, Nov 19, 2010
  5. 1/6 shift end_url_with_slash() from http.[ch] to url.[ch]Tay Ray Chuan, Nov 19, 2010
  6. 2/6 url: add str wrapper for end_url_with_slash()Tay Ray Chuan, Nov 19, 2010
  7. 3/6 http-push: Normalise directory names when pushing to some WebDAV serversTay Ray Chuan, Nov 19, 2010
  8. 4/6 http-backend: use end_url_with_slash()Tay Ray Chuan, Nov 19, 2010
  9. 5/6 http-push: check path length before using itTay Ray Chuan, Nov 19, 2010
  10. 6/6 http-push: add trailing slash at arg-parse time, instead of later onTay Ray Chuan, Nov 19, 2010
  11. Jonathan NiederNov 19, 2010
  12. Tay Ray ChuanNov 20, 2010
  13. Jonathan NiederNov 19, 2010
  14. Junio C HamanoNov 19, 2010
  15. Tay Ray ChuanNov 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.