git: 9front

Download patch

ref: 153be89c721b0bd4eabd579de115c45bcfa35e0a
parent: a70ccb01c62471f3305e52f08c04632afd4c4098
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Sun Sep 4 23:30:07 EDT 2011

webfs: fix broken baseurl handling

--- a/sys/src/cmd/webfs/client.c
+++ b/sys/src/cmd/webfs/client.c
@@ -225,6 +225,7 @@
 	Bool,
 	Int,
 	String,
+	XRel,
 	XUrl,
 	Fn,
 };
@@ -253,7 +254,7 @@
 
 Ctab clienttab[] = {
 	"baseurl",			XUrl,		(void*)offsetof(Client, baseurl),
-	"url",				XUrl,		(void*)offsetof(Client, url),
+	"url",				XRel,		(void*)offsetof(Client, url),
 };
 
 static Ctab*
@@ -270,9 +271,10 @@
 static void
 parseas(Req *r, char *arg, int type, void *a)
 {
-	Url *u;
+	Url *u, *base;
 	char e[ERRMAX];
 
+	base = nil;
 	switch(type){
 	case Bool:
 		if(strcmp(arg, "on")==0 || strcmp(arg, "1")==0)
@@ -284,8 +286,10 @@
 		free(*(char**)a);
 		*(char**)a = estrdup(arg);
 		break;
+	case XRel:
+		base = ((Client*)a)->baseurl;
 	case XUrl:
-		u = parseurl(arg, nil);
+		u = parseurl(arg, base);
 		if(u == nil){
 			snprint(e, sizeof e, "parseurl: %r");
 			respond(r, e);
--- a/sys/src/cmd/webfs/dat.h
+++ b/sys/src/cmd/webfs/dat.h
@@ -24,6 +24,7 @@
 {
 	Url	*url;
 	Url	*baseurl;
+
 	Ctl ctl;
 	Channel *creq;	/* chan(Req*) */
 	int num;
--