diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index 201959762..0fb528a7f 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -243,7 +243,7 @@ char *unquot(char *dst, char *src, int len){ char *e; e=0; - while(strchr("\n\r\t ", *src)) + while(*src && strchr(" \t\r\n", *src)) src++; if(*src=='\'' || *src=='"'){ e=strrchr(src+1, *src); diff --git a/sys/src/cmd/uhtml.c b/sys/src/cmd/uhtml.c index 6c9de188e..9d7ef4422 100644 --- a/sys/src/cmd/uhtml.c +++ b/sys/src/cmd/uhtml.c @@ -5,6 +5,7 @@ int nbuf; char buf[64*1024+1]; char *cset = nil; +char *whitespace = " \t\r\n"; void usage(void) @@ -21,11 +22,11 @@ attr(char *s, char *a) if((s = cistrstr(s, a)) == nil) return nil; s += strlen(a); - while(strchr("\r\n\t ", *s)) + while(*s && strchr(whitespace, *s)) s++; if(*s++ != '=') return nil; - while(strchr("\r\n\t ", *s)) + while(*s && strchr(whitespace, *s)) s++; q = 0; if(*s == '"' || *s == '\'') diff --git a/sys/src/cmd/webfs/dat.h b/sys/src/cmd/webfs/dat.h index 60dd0870c..b6aab58e8 100644 --- a/sys/src/cmd/webfs/dat.h +++ b/sys/src/cmd/webfs/dat.h @@ -67,3 +67,4 @@ struct Buq int debug; Url *proxy; int timeout; +char *whitespace; diff --git a/sys/src/cmd/webfs/fs.c b/sys/src/cmd/webfs/fs.c index 5e803d07d..b513ec114 100644 --- a/sys/src/cmd/webfs/fs.c +++ b/sys/src/cmd/webfs/fs.c @@ -613,7 +613,7 @@ clientctl(Client *cl, char *ctl, char *arg) else if(!strcmp(ctl, "headers")){ while(arg && *arg){ ctl = arg; - while(*ctl && strchr("\r\n\t ", *ctl)) + while(*ctl && strchr(whitespace, *ctl)) ctl++; if(arg = strchr(ctl, '\n')) *arg++ = 0; @@ -663,9 +663,9 @@ fswrite(Req *r) n--; s[n] = 0; t = s; - while(*t && strchr("\r\n\t ", *t)==0) + while(*t && strchr(whitespace, *t)==0) t++; - while(*t && strchr("\r\n\t ", *t)) + while(*t && strchr(whitespace, *t)) *t++ = 0; if(f->level == Qctl) t = clientctl(f->client, s, t); diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index 6562b9815..04882b138 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -274,9 +274,9 @@ hline(Hconn *h, char *data, int len, int cont) if(n > 0 && cont){ e = h->buf + h->len; for(y = x+1; y < e; y++) - if(!strchr("\t ", *y)) + if(*y != ' ' && *y != '\t') break; - if(y >= e || strchr("\t ", *y)) + if(y >= e || *y == 0) break; if(y > x+1){ if(x > h->buf && x[-1] == '\r') diff --git a/sys/src/cmd/webfs/sub.c b/sys/src/cmd/webfs/sub.c index b8ca1e3ac..476e5fd26 100644 --- a/sys/src/cmd/webfs/sub.c +++ b/sys/src/cmd/webfs/sub.c @@ -8,6 +8,8 @@ #include "dat.h" #include "fns.h" +char *whitespace = " \t\r\n"; + void* emalloc(int n) { @@ -85,12 +87,14 @@ parsehdr(char *s) { char *v; + if(*s == 0) + return nil; v = strchr(s, 0)-1; - while(v >= s && strchr("\n\r\t ", *v)) + while(v >= s && strchr(whitespace, *v)) *v-- = 0; if(v = strchr(s, ':')){ *v++ = 0; - while(strchr("\t ", *v)) + while(*v == ' ' || *v == '\t') v++; if(*s && *v) return addkey(0, s, v);