# [PATCH] http-push.c: DAV must support olny http and https scheme

2 messages from 2009-04-13 to 2009-04-13. Participants: Kirill A. Korinskiy.
Thread: https://gitlist.dev/t/18846

## Kirill A. Korinskiy, 2009-04-13 12:42

Subject: [PATCH] http-push.c: DAV must support olny http and https scheme
Message-ID: <1239626554-26206-1-git-send-email-catap@catap.ru>
URL: https://gitlist.dev/e/1239626554-26206-1-git-send-email-catap%40catap.ru

```
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

```

## Kirill A. Korinskiy, 2009-04-13 17:00

Subject: [PATCH] http-push.c: DAV must support only http and https scheme
Message-ID: <1239642037-20352-1-git-send-email-catap@catap.ru>
URL: https://gitlist.dev/e/1239642037-20352-1-git-send-email-catap%40catap.ru
In-Reply-To: <1239626554-26206-1-git-send-email-catap@catap.ru>

```
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

```
