git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Normalise directory names when pushing to some WebDAV servers
@ 2010-11-19  0:06 Gabriel Corona
  2010-11-19  4:02 ` Tay Ray Chuan
  0 siblings, 1 reply; 15+ messages in thread
From: Gabriel Corona @ 2010-11-19  0:06 UTC (permalink / raw)
  To: git; +Cc: Gabriel Corona

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-20  4:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19  0:06 [PATCH] Normalise directory names when pushing to some WebDAV servers Gabriel Corona
2010-11-19  4:02 ` Tay Ray Chuan
2010-11-19  5:10   ` Jonathan Nieder
2010-11-19 12:46     ` [PATCH 0/6] http (dumb): end urls with slash Tay Ray Chuan
2010-11-19 12:46       ` [PATCH 1/6] shift end_url_with_slash() from http.[ch] to url.[ch] Tay Ray Chuan
2010-11-19 12:46         ` [PATCH 2/6] url: add str wrapper for end_url_with_slash() Tay Ray Chuan
2010-11-19 12:46           ` [PATCH 3/6] http-push: Normalise directory names when pushing to some WebDAV servers Tay Ray Chuan
2010-11-19 12:46             ` [PATCH 4/6] http-backend: use end_url_with_slash() Tay Ray Chuan
2010-11-19 12:46               ` [PATCH 5/6] http-push: check path length before using it Tay Ray Chuan
2010-11-19 12:46                 ` [PATCH 6/6] http-push: add trailing slash at arg-parse time, instead of later on Tay Ray Chuan
2010-11-19 18:33                 ` [PATCH 5/6] http-push: check path length before using it Jonathan Nieder
2010-11-20  4:28                   ` Tay Ray Chuan
2010-11-19 19:18       ` [PATCH 0/6] http (dumb): end urls with slash Jonathan Nieder
2010-11-19 22:54       ` Junio C Hamano
2010-11-20  4:32         ` Tay Ray Chuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).