aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-tag.c
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2012-10-26 16:54:12 -0400
committerGravatar David Bremner <bremner@debian.org>2012-10-27 09:32:44 -0300
commite0a223d15656a8a8fd6564687425a7e583f29b61 (patch)
tree5cb209f66a0a7f83fa075f3b5a9097f08d350bf3 /notmuch-tag.c
parent02cafc84b4540cd0fb878121dcb3551b4ecd9fd1 (diff)
tag: Disallow adding malformed tags to messages
This disallows adding empty tags, since nothing but confusion follows in their wake, and disallows adding tags that begin with "-" because they are also confusing, the tag "-" is impossible to remove using the CLI, and because the syntax for removing such tags conflicts with long argument syntax. This does not place any restrictions on what tags can be removed, as that would make it difficult for people who have the misfortune of already having malformed tags to remove these tags.
Diffstat (limited to 'notmuch-tag.c')
-rw-r--r--notmuch-tag.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 7d186399..d15f1eda 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -203,6 +203,17 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
break;
}
if (argv[i][0] == '+' || argv[i][0] == '-') {
+ if (argv[i][0] == '+' && argv[i][1] == '\0') {
+ fprintf(stderr, "Error: tag names cannot be empty.\n");
+ return 1;
+ }
+ if (argv[i][0] == '+' && argv[i][1] == '-') {
+ /* This disallows adding the non-removable tag "-" and
+ * enables notmuch tag to take long options in the
+ * future. */
+ fprintf(stderr, "Error: tag names must not start with '-'.\n");
+ return 1;
+ }
tag_ops[tag_ops_count].tag = argv[i] + 1;
tag_ops[tag_ops_count].remove = (argv[i][0] == '-');
tag_ops_count++;