mirror of
https://github.com/0intro/wmii
synced 2025-01-26 12:02:23 +03:00
trim whitespace from tags before validating them, fixes the issue seen when trying to tag a client with a whitespace only tag
This commit is contained in:
parent
9af4c39943
commit
94a8bd0c3c
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user