wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 94a8bd0c3c019e51ffb1aab01c1b7f06ec1e2b98
parent 9af4c399431b7a9677229e572c9f79e900b3df0f
Author: Sander van Dijk <sander@wmii.de>
Date:   Sun,  7 May 2006 19:56:05 +0000

trim whitespace from tags before validating them, fixes the issue seen when trying to tag a client with a whitespace only tag


Diffstat:
cmd/wm/fs.c | 2+-
cmd/wm/rule.c | 5+++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -1362,6 +1362,7 @@ xwrite(IXPConn *c, Fcall *fcall) return Ebadvalue; memcpy(buf, fcall->data, fcall->count); buf[fcall->count] = 0; + cext_trim(buf, " \t"); if(!permit_tags(buf)) return Ebadvalue; if(dir_type == FsDclient) @@ -1369,7 +1370,6 @@ xwrite(IXPConn *c, Fcall *fcall) else cl = client.data[i1]; cext_strlcpy(cl->tags, buf, sizeof(cl->tags)); - cext_trim(cl->tags, " \t"); update_views(); draw_client(cl); break; diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c @@ -56,7 +56,8 @@ permit_tags(const char *tags) unsigned int i, j, n; cext_strlcpy(buf, tags, sizeof(buf)); - n = cext_tokenize(toks, 16, buf, '+'); + if(!(n = cext_tokenize(toks, 16, buf, '+'))) + return False; for(i = 0; i < (sizeof(exclude)/sizeof(exclude[0])); i++) for(j = 0; j < n; j++) { if(!strncmp(exclude[i], toks[j], strlen(toks[j])) && @@ -110,11 +111,11 @@ update_rules() case TAGS: if(*p == '\n' || *(p + 1) == 0) { *t = 0; + cext_trim(tags, " \t"); if(permit_tags(tags)) { Rule *rul = cext_emallocz(sizeof(Rule)); rul->is_valid = !regcomp(&rul->regex, regex, 0); cext_strlcpy(rul->tags, tags, sizeof(rul->tags)); - cext_trim(rul->tags, " \t"); cext_vattach(vector_of_rules(&rule), rul); } else