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 7DA8F431FBC for ; Thu, 13 Dec 2012 14:07:38 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 4o2c+Vw3a0TM for ; Thu, 13 Dec 2012 14:07:38 -0800 (PST) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C0A70431FB6 for ; Thu, 13 Dec 2012 14:07:37 -0800 (PST) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1TjGwF-0003Wm-7C; Thu, 13 Dec 2012 22:07:33 +0000 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1TjGwE-0005vV-UR; Thu, 13 Dec 2012 22:07:31 +0000 From: Mark Walters To: david@tethera.net, notmuch@notmuchmail.org Subject: Re: [Patch v6 1/6] tag-util: factor out rules for illegal tags, use in parse_tag_line In-Reply-To: <1355096008-4544-2-git-send-email-david@tethera.net> References: <1355096008-4544-1-git-send-email-david@tethera.net> <1355096008-4544-2-git-send-email-david@tethera.net> User-Agent: Notmuch/0.14+155~g7edfdc3 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Thu, 13 Dec 2012 22:07:32 +0000 Message-ID: <871uettxln.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 58d2b61d88fae9d87e3bd6eab48cee79 (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean Cc: David Bremner 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: Thu, 13 Dec 2012 22:07:38 -0000 I don't know if this matters but it seems that one can still add a "-" tag by doing something like echo "+%2d -- search" | notmuch tag --batch This might be the right thing to do but I thought I would mention it. Best wishes Mark On Sun, 09 Dec 2012, david@tethera.net wrote: > From: David Bremner > > This will allow us to be consistent between batch tagging and command > line tagging as far as what is an illegal tag. > --- > tag-util.c | 35 ++++++++++++++++++++++++++++++----- > 1 file changed, 30 insertions(+), 5 deletions(-) > > diff --git a/tag-util.c b/tag-util.c > index eab482f..c071ea8 100644 > --- a/tag-util.c > +++ b/tag-util.c > @@ -31,6 +31,29 @@ line_error (tag_parse_status_t status, > return status; > } > > +/* > + * Test tags for some forbidden cases. > + * > + * return: NULL if OK, > + * explanatory message otherwise. > + */ > + > +static const char * > +illegal_tag (const char *tag, notmuch_bool_t remove) { > + > + if (*tag == '\0' && !remove) > + return "adding empty tag"; > + > + /* This disallows adding the non-removable tag "-" and > + * enables notmuch tag to take long options more easily. > + */ > + > + if (*tag == '-' && !remove) > + return "adding tag starting with -"; > + > + return NULL; > +} > + > tag_parse_status_t > parse_tag_line (void *ctx, char *line, > tag_op_flag_t flags, > @@ -95,11 +118,13 @@ parse_tag_line (void *ctx, char *line, > remove = (*tok == '-'); > tag = tok + 1; > > - /* Maybe refuse empty tags. */ > - if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') { > - ret = line_error (TAG_PARSE_INVALID, line_for_error, > - "empty tag"); > - goto DONE; > + /* Maybe refuse illegal tags. */ > + if (! (flags & TAG_FLAG_BE_GENEROUS)) { > + const char *msg = illegal_tag (tag, remove); > + if (msg) { > + ret = line_error (TAG_PARSE_INVALID, line_for_error, msg); > + goto DONE; > + } > } > > /* Decode tag. */ > -- > 1.7.10.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch