@matheusbsbs / matheus-bagliano / commits / e1f33efe07
Fork 0

http-push: support full URI in handle_remote_ls_ctx()

The program calls remote_ls() to get list of files from the server over HTTP; handle_remote_ls_ctx() is used to parse its response to populate "struct remote_ls_ctx" that is returned from remote_ls(). The handle_remote_ls_ctx() function assumed that the server returns a local path in href field, but RFC 4918 (14.7) demand of support full URI (e.g. "http://localhost:8080/repo.git"). This resulted in push failure (e.g. git-http-push issues a PROPFIND request to "/repo.git/alhost:8080/repo.git/refs/" to the server). Signed-off-by: Kirill A. Korinskiy <catap@catap.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kirill A. Korinskiy committed Dec 23, 2008 at 11:31 UTC e1f33efe07b9a520505fccd71bea1292fc9448dd
1 file changed +19 -6
http-push.c
+19 -6
@@ -87,6 +87,7 @@ static struct object_list *objects;
87 struct repo
88 {
89 char *url;
90 + char *path;
91 int path_len;
92 int has_info_refs;
93 int can_update_info_refs;
@@ -1424,9 +1425,19 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
1425 ls->userFunc(ls);
1426 }
1427 } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
1427 - ls->dentry_name = xmalloc(strlen(ctx->cdata) -
1428 + char *path = ctx->cdata;
1429 + if (*ctx->cdata == 'h') {
1430 + path = strstr(path, "//");
1431 + if (path) {
1432 + path = strchr(path+2, '/');
1433 + }
1434 + }
1435 + if (path) {
1436 + path += remote->path_len;
1437 + }
1438 + ls->dentry_name = xmalloc(strlen(path) -
1439 remote->path_len + 1);
1429 - strcpy(ls->dentry_name, ctx->cdata + remote->path_len);
1440 + strcpy(ls->dentry_name, path + remote->path_len);
1441 } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
1442 ls->dentry_flags |= IS_DIR;
1443 }
@@ -2206,10 +2217,11 @@ int main(int argc, char **argv)
2217 if (!remote->url) {
2218 char *path = strstr(arg, "//");
2219 remote->url = arg;
2220 + remote->path_len = strlen(arg);
2221 if (path) {
2210 - path = strchr(path+2, '/');
2211 - if (path)
2212 - remote->path_len = strlen(path);
2222 + remote->path = strchr(path+2, '/');
2223 + if (remote->path)
2224 + remote->path_len = strlen(remote->path);
2225 }
2226 continue;
2227 }
@@ -2238,8 +2250,9 @@ int main(int argc, char **argv)
2250 rewritten_url = xmalloc(strlen(remote->url)+2);
2251 strcpy(rewritten_url, remote->url);
2252 strcat(rewritten_url, "/");
2253 + remote->path = rewritten_url + (remote->path - remote->url);
2254 + remote->path_len++;
2255 remote->url = rewritten_url;
2242 - ++remote->path_len;
2256 }
2257
2258 /* Verify DAV compliance/lock support */