webfs: properly handle %.*s in url path and debug prints

This commit is contained in:
cinap_lenrek 2019-02-25 03:21:09 +01:00
parent 05227960c6
commit e1dcd2beb4
2 changed files with 4 additions and 4 deletions

View file

@ -663,7 +663,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
for(;;){
if(n >= sizeof(buf)-2){
if(debug)
fprint(2, "-> %.*s", n, buf);
fprint(2, "-> %.*s", utfnlen(buf, n), buf);
if(hwrite(h, buf, n) != n)
goto Badflush;
n = 0;
@ -685,7 +685,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
continue;
if(n > 0){
if(debug)
fprint(2, "-> %.*s", n, buf);
fprint(2, "-> %.*s", utfnlen(buf, n), buf);
if(hwrite(h, buf, n) != n)
goto Badflush;
}
@ -693,7 +693,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
}
n += snprint(buf+n, sizeof(buf)-n, "\r\n");
if(debug)
fprint(2, "-> %.*s", n, buf);
fprint(2, "-> %.*s", utfnlen(buf, n), buf);
if(hwrite(h, buf, n) != n){
Badflush:
alarm(0);

View file

@ -169,7 +169,7 @@ abspath(char *s, char *b)
return estrdup(b);
if(*s != '/' && (x = strrchr(b, '/'))){
a = emalloc((x - b) + strlen(s) + 4);
sprint(a, "%.*s/%s", (int)(x - b), b, s);
sprint(a, "%.*s/%s", utfnlen(b, x - b), b, s);
return remdot(a);
}
}