* [PATCH] http-push.c: DAV must support olny http and https scheme
@ 2009-04-10 13:44 Kirill A. Korinskiy
2009-04-12 8:48 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Kirill A. Korinskiy @ 2009-04-10 13:44 UTC (permalink / raw
To: gitster, git; +Cc: Kirill A. Korinskiy
If the response from remote web-server have scp or other not http-like
scheme http-push can't go to change url, because DAV must work only
over HTTP (http and https scheme).
Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
---
http-push.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/http-push.c b/http-push.c
index feeb340..48c9a04 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1457,16 +1457,17 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
}
} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
char *path = ctx->cdata;
- if (*ctx->cdata == 'h') {
- path = strstr(path, "//");
- if (path) {
- path = strchr(path+2, '/');
- }
- }
- if (path) {
- path += repo->path_len;
- ls->dentry_name = xstrdup(path);
+ if (!strcmp(ctx->cdata, "http://")) {
+ path = strchr(path + sizeof("http://") - 1, '/');
+ } else if (!strcmp(ctx->cdata, "https://")) {
+ path = strchr(path + sizeof("https://") - 1, '/');
}
+
+ path += remote->path_len;
+
+ ls->dentry_name = xmalloc(strlen(path) -
+ remote->path_len + 1);
+ strcpy(ls->dentry_name, path + remote->path_len);
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
ls->dentry_flags |= IS_DIR;
}
--
1.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-10 13:44 [PATCH] http-push.c: DAV must support olny http and https scheme Kirill A. Korinskiy
@ 2009-04-12 8:48 ` Junio C Hamano
2009-04-12 9:00 ` Mike Hommey
2009-04-12 18:49 ` Kirill A. Korinskiy
0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-04-12 8:48 UTC (permalink / raw
To: Kirill A. Korinskiy; +Cc: git
"Kirill A. Korinskiy" <catap@catap.ru> writes:
> If the response from remote web-server have scp or other not http-like
> scheme http-push can't go to change url, because DAV must work only
> over HTTP (http and https scheme).
>
> Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
> ---
> http-push.c | 19 ++++++++++---------
> 1 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/http-push.c b/http-push.c
> index feeb340..48c9a04 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -1457,16 +1457,17 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
> }
> } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
> char *path = ctx->cdata;
> - if (*ctx->cdata == 'h') {
> - path = strstr(path, "//");
> - if (path) {
> - path = strchr(path+2, '/');
> - }
> - }
> - if (path) {
> - path += repo->path_len;
> - ls->dentry_name = xstrdup(path);
> + if (!strcmp(ctx->cdata, "http://")) {
> + path = strchr(path + sizeof("http://") - 1, '/');
> + } else if (!strcmp(ctx->cdata, "https://")) {
> + path = strchr(path + sizeof("https://") - 1, '/');
> }
> +
> + path += remote->path_len;
http-push.c: In function 'handle_remote_ls_ctx':
http-push.c:1466: error: 'remote' undeclared (first use in this function)
http-push.c:1466: error: (Each undeclared identifier is reported only once
http-push.c:1466: error: for each function it appears in.)
Ah, crap.
> + ls->dentry_name = xmalloc(strlen(path) -
> + remote->path_len + 1);
> + strcpy(ls->dentry_name, path + remote->path_len);
> } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
> ls->dentry_flags |= IS_DIR;
> }
> --
> 1.6.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-12 8:48 ` Junio C Hamano
@ 2009-04-12 9:00 ` Mike Hommey
2009-04-12 18:45 ` Junio C Hamano
2009-04-12 18:49 ` Kirill A. Korinskiy
1 sibling, 1 reply; 8+ messages in thread
From: Mike Hommey @ 2009-04-12 9:00 UTC (permalink / raw
To: Junio C Hamano; +Cc: Kirill A. Korinskiy, git
On Sun, Apr 12, 2009 at 01:48:05AM -0700, Junio C Hamano wrote:
> "Kirill A. Korinskiy" <catap@catap.ru> writes:
>
> > If the response from remote web-server have scp or other not http-like
> > scheme http-push can't go to change url, because DAV must work only
> > over HTTP (http and https scheme).
> >
> > Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
> > ---
> > http-push.c | 19 ++++++++++---------
> > 1 files changed, 10 insertions(+), 9 deletions(-)
> >
> > diff --git a/http-push.c b/http-push.c
> > index feeb340..48c9a04 100644
> > --- a/http-push.c
> > +++ b/http-push.c
> > @@ -1457,16 +1457,17 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
> > }
> > } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
> > char *path = ctx->cdata;
> > - if (*ctx->cdata == 'h') {
> > - path = strstr(path, "//");
> > - if (path) {
> > - path = strchr(path+2, '/');
> > - }
> > - }
> > - if (path) {
> > - path += repo->path_len;
> > - ls->dentry_name = xstrdup(path);
> > + if (!strcmp(ctx->cdata, "http://")) {
> > + path = strchr(path + sizeof("http://") - 1, '/');
> > + } else if (!strcmp(ctx->cdata, "https://")) {
> > + path = strchr(path + sizeof("https://") - 1, '/');
> > }
> > +
> > + path += remote->path_len;
>
> http-push.c: In function 'handle_remote_ls_ctx':
> http-push.c:1466: error: 'remote' undeclared (first use in this function)
> http-push.c:1466: error: (Each undeclared identifier is reported only once
> http-push.c:1466: error: for each function it appears in.)
>
> Ah, crap.
s/remote/repo/. He must have done his patch before 7b5201a and rebased
afterwards without checking.
Mike
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-12 9:00 ` Mike Hommey
@ 2009-04-12 18:45 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-04-12 18:45 UTC (permalink / raw
To: Mike Hommey; +Cc: Kirill A. Korinskiy, git
Mike Hommey <mh@glandium.org> writes:
>> http-push.c: In function 'handle_remote_ls_ctx':
>> http-push.c:1466: error: 'remote' undeclared (first use in this function)
>> http-push.c:1466: error: (Each undeclared identifier is reported only once
>> http-push.c:1466: error: for each function it appears in.)
>>
>> Ah, crap.
>
> s/remote/repo/. He must have done his patch before 7b5201a and rebased
> afterwards without checking.
Oh, I know that.
The "crap" was about "sent without checking" part.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-12 8:48 ` Junio C Hamano
2009-04-12 9:00 ` Mike Hommey
@ 2009-04-12 18:49 ` Kirill A. Korinskiy
2009-04-12 19:33 ` Junio C Hamano
2009-04-13 16:44 ` Matthieu Moy
1 sibling, 2 replies; 8+ messages in thread
From: Kirill A. Korinskiy @ 2009-04-12 18:49 UTC (permalink / raw
To: gitster; +Cc: git, Kirill A. Korinskiy
If the response from remote web-server have scp or other not http-like
scheme http-push can't go to change url, because DAV must work only
over HTTP (http and https scheme).
Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
---
http-push.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/http-push.c b/http-push.c
index feeb340..cce9ead 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1457,16 +1457,17 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
}
} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
char *path = ctx->cdata;
- if (*ctx->cdata == 'h') {
- path = strstr(path, "//");
- if (path) {
- path = strchr(path+2, '/');
- }
- }
- if (path) {
- path += repo->path_len;
- ls->dentry_name = xstrdup(path);
+ if (!strcmp(ctx->cdata, "http://")) {
+ path = strchr(path + sizeof("http://") - 1, '/');
+ } else if (!strcmp(ctx->cdata, "https://")) {
+ path = strchr(path + sizeof("https://") - 1, '/');
}
+
+ path += repo->path_len;
+
+ ls->dentry_name = xmalloc(strlen(path) -
+ repo->path_len + 1);
+ strcpy(ls->dentry_name, path + repo->path_len);
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
ls->dentry_flags |= IS_DIR;
}
--
1.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-12 18:49 ` Kirill A. Korinskiy
@ 2009-04-12 19:33 ` Junio C Hamano
2009-04-13 16:44 ` Matthieu Moy
1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-04-12 19:33 UTC (permalink / raw
To: Kirill A. Korinskiy; +Cc: gitster, git
"Kirill A. Korinskiy" <catap@catap.ru> writes:
> If the response from remote web-server have scp or other not http-like
> scheme http-push can't go to change url, because DAV must work only
> over HTTP (http and https scheme).
>
> Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
> ---
Thanks. I was wondering about a few more things about the patch and the
original code.
> http-push.c | 19 ++++++++++---------
> 1 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/http-push.c b/http-push.c
> index feeb340..cce9ead 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -1457,16 +1457,17 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
> }
> } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
> char *path = ctx->cdata;
> - if (*ctx->cdata == 'h') {
> - path = strstr(path, "//");
> - if (path) {
> - path = strchr(path+2, '/');
> - }
> - }
> - if (path) {
> - path += repo->path_len;
> - ls->dentry_name = xstrdup(path);
The original protects against an unexpected ctx->cdata such as
http://frotz
that does not have any slash after the method:// part (in which case it
does not even set ls_dentry_name.
> + if (!strcmp(ctx->cdata, "http://")) {
> + path = strchr(path + sizeof("http://") - 1, '/');
> + } else if (!strcmp(ctx->cdata, "https://")) {
> + path = strchr(path + sizeof("https://") - 1, '/');
I wonder what happens if the strchr() returns NULL for such a broken
ctx->cdata. Will it make strlen(path) later to segfault?
Besides, obviously this patch was never tested; you meant prefixcmp, not
strcmp here, so path never becomes NULL here. Oh, and instead of
comparing with ctx->cdata it would be easier to compare against path.
> }
> +
> + path += repo->path_len;
> +
> + ls->dentry_name = xmalloc(strlen(path) -
> + repo->path_len + 1);
> + strcpy(ls->dentry_name, path + repo->path_len);
> } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
> ls->dentry_flags |= IS_DIR;
> }
> --
> 1.6.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] http-push.c: DAV must support olny http and https scheme
@ 2009-04-13 12:42 Kirill A. Korinskiy
0 siblings, 0 replies; 8+ messages in thread
From: Kirill A. Korinskiy @ 2009-04-13 12:42 UTC (permalink / raw
To: gitster; +Cc: git, Kirill A. Korinskiy
If the response from remote web-server have scp or other not http-like
scheme http-push can't go to change url, because DAV must work only
over HTTP (http and https scheme).
Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>
---
http-push.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/http-push.c b/http-push.c
index 5138224..79c8201 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1486,16 +1486,23 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
}
} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
char *path = ctx->cdata;
- if (*ctx->cdata == 'h') {
- path = strstr(path, "//");
- if (path) {
- path = strchr(path+2, '/');
- }
+
+ if (!strncasecmp(ctx->cdata, "http://", sizeof("http://") - 1)) {
+ path = strchr(path + sizeof("http://") - 1, '/');
+ } else if (!strncasecmp(ctx->cdata, "https://",
+ sizeof("https://") - 1)) {
+ path = strchr(path + sizeof("https://") - 1, '/');
+ } else if (strstr(path, "://")) {
+ path = NULL;
}
+
if (path) {
path += repo->path_len;
ls->dentry_name = xstrdup(path);
+ } else {
+ fprintf(stderr, "Not valid URI: %s\n", ctx->cdata);
}
+
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
ls->dentry_flags |= IS_DIR;
}
--
1.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] http-push.c: DAV must support olny http and https scheme
2009-04-12 18:49 ` Kirill A. Korinskiy
2009-04-12 19:33 ` Junio C Hamano
@ 2009-04-13 16:44 ` Matthieu Moy
1 sibling, 0 replies; 8+ messages in thread
From: Matthieu Moy @ 2009-04-13 16:44 UTC (permalink / raw
To: Kirill A. Korinskiy; +Cc: gitster, git
"Kirill A. Korinskiy" <catap@catap.ru> writes:
> Subject: [PATCH] http-push.c: DAV must support olny http and https scheme
^^
s/olny/only/ if it's not too late.
--
Matthieu
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-04-13 16:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-10 13:44 [PATCH] http-push.c: DAV must support olny http and https scheme Kirill A. Korinskiy
2009-04-12 8:48 ` Junio C Hamano
2009-04-12 9:00 ` Mike Hommey
2009-04-12 18:45 ` Junio C Hamano
2009-04-12 18:49 ` Kirill A. Korinskiy
2009-04-12 19:33 ` Junio C Hamano
2009-04-13 16:44 ` Matthieu Moy
-- strict thread matches above, loose matches on Subject: below --
2009-04-13 12:42 Kirill A. Korinskiy
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).