Skip to content

Commit

Permalink
http-push: support full URI in handle_remote_ls_ctx()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kirill A. Korinskiy authored and Junio C Hamano committed Dec 25, 2008
1 parent 8104ebf commit e1f33ef
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static struct object_list *objects;
struct repo
{
char *url;
char *path;
int path_len;
int has_info_refs;
int can_update_info_refs;
Expand Down Expand Up @@ -1424,9 +1425,19 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
ls->userFunc(ls);
}
} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
ls->dentry_name = xmalloc(strlen(ctx->cdata) -
char *path = ctx->cdata;
if (*ctx->cdata == 'h') {
path = strstr(path, "//");
if (path) {
path = strchr(path+2, '/');
}
}
if (path) {
path += remote->path_len;
}
ls->dentry_name = xmalloc(strlen(path) -
remote->path_len + 1);
strcpy(ls->dentry_name, ctx->cdata + remote->path_len);
strcpy(ls->dentry_name, path + remote->path_len);
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
ls->dentry_flags |= IS_DIR;
}
Expand Down Expand Up @@ -2206,10 +2217,11 @@ int main(int argc, char **argv)
if (!remote->url) {
char *path = strstr(arg, "//");
remote->url = arg;
remote->path_len = strlen(arg);
if (path) {
path = strchr(path+2, '/');
if (path)
remote->path_len = strlen(path);
remote->path = strchr(path+2, '/');
if (remote->path)
remote->path_len = strlen(remote->path);
}
continue;
}
Expand Down Expand Up @@ -2238,8 +2250,9 @@ int main(int argc, char **argv)
rewritten_url = xmalloc(strlen(remote->url)+2);
strcpy(rewritten_url, remote->url);
strcat(rewritten_url, "/");
remote->path = rewritten_url + (remote->path - remote->url);
remote->path_len++;
remote->url = rewritten_url;
++remote->path_len;
}

/* Verify DAV compliance/lock support */
Expand Down

0 comments on commit e1f33ef

Please sign in to comment.