parse_csv_taglist() now skips empty tags

Wed, 30 May 2018 16:51:52 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 30 May 2018 16:51:52 +0200
changeset 393
438c8fe7d62f
parent 392
4853fbad5014
child 394
4826f5fdd865

parse_csv_taglist() now skips empty tags

dav/tags.c file | annotate | diff | comparison | revisions
--- a/dav/tags.c	Wed May 30 16:49:25 2018 +0200
+++ b/dav/tags.c	Wed May 30 16:51:52 2018 +0200
@@ -97,10 +97,13 @@
     ssize_t count = 0;
     sstr_t *tags = sstrsplit(str, S(","), &count);
     for(int i=0;i<count;i++) {
-        DavTag *tag = malloc(sizeof(DavTag));
-        tag->name = sstrdup(sstrtrim(tags[i])).ptr;
-        tag->color = NULL;
-        taglist = ucx_list_append(taglist, tag);
+        sstr_t trimmed_tag = sstrtrim(tags[i]);
+        if (trimmed_tag.length > 0) {
+            DavTag *tag = malloc(sizeof(DavTag));
+            tag->name = sstrdup(trimmed_tag).ptr;
+            tag->color = NULL;
+            taglist = ucx_list_append(taglist, tag);
+        }
         free(tags[i].ptr);
     }
     if(tags) {

mercurial