Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D0020431FAF for ; Fri, 26 Oct 2012 14:17:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t0zfboOm9qYh for ; Fri, 26 Oct 2012 14:17:41 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 53F3E431FAE for ; Fri, 26 Oct 2012 14:17:41 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 72792100045; Sat, 27 Oct 2012 00:17:43 +0300 (EEST) From: Tomi Ollila To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH 1/2] tag: Disallow adding malformed tags to messages In-Reply-To: <1351284853-24809-1-git-send-email-amdragon@mit.edu> References: <1351284853-24809-1-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.14+59~gf9031cd (http://notmuchmail.org) Emacs/24.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2012 21:17:42 -0000 On Fri, Oct 26 2012, Austin Clements wrote: > 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. > --- LGTM (NEWS too) Tomi > notmuch-tag.c | 11 +++++++++++ > test/tagging | 4 ++++ > 2 files changed, 15 insertions(+) > > diff --git a/notmuch-tag.c b/notmuch-tag.c > index 7d18639..d15f1ed 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++; > diff --git a/test/tagging b/test/tagging > index e4782ed..980ff92 100755 > --- a/test/tagging > +++ b/test/tagging > @@ -46,4 +46,8 @@ test_expect_equal "$output" "\ > thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread) > thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)" > > +test_expect_code 1 "Empty tag names" 'notmuch tag + One' > + > +test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One' > + > test_done > -- > 1.7.10 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch