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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 19, 2010 at 8:06 AM, Gabriel Corona
<gabriel.corona@xxxxxxxxxxxxxxxx> wrote:
>  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);
>                                }
> --

Hmm, we already have the logic to do this in end_url_with_slash(). It
works on strbufs though. How about this?

-->8--

diff --git a/http-push.c b/http-push.c
index c9bcd11..645c2b5 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1086,10 +1086,15 @@ static void process_ls_ref(struct remote_ls_ctx *ls)
 static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
 {
        struct remote_ls_ctx *ls = (struct remote_ls_ctx *)ctx->userData;
+       struct strbuf buf = STRBUF_INIT;

        if (tag_closed) {
                if (!strcmp(ctx->name, DAV_PROPFIND_RESP) && ls->dentry_name) {
                        if (ls->dentry_flags & IS_DIR) {
+                               end_url_with_slash(&buf, ls->dentry_name);
+                               free(ls->dentry_name);
+                               ls->dentry_name = strbuf_detach(&buf, NULL);
+
                                if (ls->flags & PROCESS_DIRS) {
                                        ls->userFunc(ls);
                                }

-- 
Cheers,
Ray Chuan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]