shithub: riscv

Download patch

ref: 1628c97d1ee667908372a41be8e33720047723b5
parent: 9e08127ba6a4754fae8afcc6bca9d8b299180632
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Apr 15 19:54:00 EDT 2016

webfs: change %H (hostname) format to %N to not collide with encodefmt's %H (hex)

--- a/sys/src/cmd/webfs/fns.h
+++ b/sys/src/cmd/webfs/fns.h
@@ -14,9 +14,10 @@
 /* url */
 #pragma	varargck type "U" Url*
 #pragma varargck type "E" Str2
+#pragma varargck type "N" char*
 
 int	Efmt(Fmt*);
-int	Hfmt(Fmt*);
+int	Nfmt(Fmt*);
 int	Ufmt(Fmt*);
 char*	Upath(Url *);
 Url*	url(char *s, Url *b);
--- a/sys/src/cmd/webfs/fs.c
+++ b/sys/src/cmd/webfs/fs.c
@@ -418,7 +418,7 @@
 				 */
 				if(u = url("/", cl->url)){
 					if(r = u->host){
-						u->host = smprint("%H", r);
+						u->host = smprint("%N", r);
 						free(r);
 					}
 
@@ -792,9 +792,10 @@
 
 	quotefmtinstall();
 	fmtinstall('U', Ufmt);
-	fmtinstall('H', Hfmt);
+	fmtinstall('N', Nfmt);
 	fmtinstall('E', Efmt);
 	fmtinstall('[', encodefmt);
+	fmtinstall('H', encodefmt);
 
 	mtpt = "/mnt/web";
 	user = getuser();
--- a/sys/src/cmd/webfs/http.c
+++ b/sys/src/cmd/webfs/http.c
@@ -81,7 +81,7 @@
 	if(debug)
 		conn.trace = tlstrace;
 	if(servername != nil)
-		conn.serverName = smprint("%H", servername);
+		conn.serverName = smprint("%N", servername);
 	if((fd = tlsClient(fd, &conn)) < 0){
 		if(debug) fprint(2, "tlsClient: %r\n");
 		return -1;
@@ -428,7 +428,7 @@
 		fmtprint(&fmt, "Digest ");
 		fmtprint(&fmt, "username=\"%s\", ", ouser);
 		fmtprint(&fmt, "realm=\"%s\", ", realm);
-		fmtprint(&fmt, "host=\"%H\", ", u->host);
+		fmtprint(&fmt, "host=\"%N\", ", u->host);
 		fmtprint(&fmt, "uri=\"%U\", ", ru);
 		fmtprint(&fmt, "nonce=\"%s\", ", nonce);
 		fmtprint(&fmt, "response=\"%s\"", resp);
@@ -608,7 +608,7 @@
 
 		/* http requires ascii encoding of host */
 		free(host);
-		host = smprint("%H", u->host);
+		host = smprint("%N", u->host);
 
 		if(proxy && strcmp(u->scheme, "https") != 0){
 			ru = *u;
--- a/sys/src/cmd/webfs/url.c
+++ b/sys/src/cmd/webfs/url.c
@@ -69,7 +69,7 @@
 }
 
 int
-Hfmt(Fmt *f)
+Nfmt(Fmt *f)
 {
 	char *d, *s;