1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id A184C429E25
\r
6 for <notmuch@notmuchmail.org>; Thu, 10 Nov 2011 13:14:38 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id c0h1OHPn5cil for <notmuch@notmuchmail.org>;
\r
17 Thu, 10 Nov 2011 13:14:38 -0800 (PST)
\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com
\r
19 [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id D6FCD431FB6
\r
22 for <notmuch@notmuchmail.org>; Thu, 10 Nov 2011 13:14:37 -0800 (PST)
\r
23 Received: by faan15 with SMTP id n15so3758488faa.26
\r
24 for <notmuch@notmuchmail.org>; Thu, 10 Nov 2011 13:14:36 -0800 (PST)
\r
25 Received: by 10.223.6.15 with SMTP id 15mr14472817fax.4.1320959676549;
\r
26 Thu, 10 Nov 2011 13:14:36 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id g25sm12716529fae.16.2011.11.10.13.14.35
\r
30 (version=SSLv3 cipher=OTHER); Thu, 10 Nov 2011 13:14:35 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH 1/1] cli: add some constraints to tags
\r
34 Date: Thu, 10 Nov 2011 23:14:31 +0200
\r
36 <3da260c7687fafe2cbc17bad129a8b1edb05c6d0.1320958534.git.jani@nikula.org>
\r
37 X-Mailer: git-send-email 1.7.5.4
\r
38 In-Reply-To: <cover.1320958534.git.jani@nikula.org>
\r
39 References: <cover.1320958534.git.jani@nikula.org>
\r
40 In-Reply-To: <cover.1320958534.git.jani@nikula.org>
\r
41 References: <cover.1320958534.git.jani@nikula.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Thu, 10 Nov 2011 21:14:38 -0000
\r
56 Forbid zero length tags, tags with leading '-', tags with leading or
\r
57 trailing whitespace, and tags containing whitespace other than space ' '.
\r
59 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
61 notmuch-client.h | 1 +
\r
62 notmuch-tag.c | 20 ++++++++++++++++++++
\r
63 2 files changed, 21 insertions(+), 0 deletions(-)
\r
65 diff --git a/notmuch-client.h b/notmuch-client.h
\r
66 index b50cb38..ff286b0 100644
\r
67 --- a/notmuch-client.h
\r
68 +++ b/notmuch-client.h
\r
77 diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
78 index dded39e..fb7a2f3 100644
\r
81 @@ -30,6 +30,22 @@ handle_sigint (unused (int sig))
\r
86 +tag_valid(const char *tag)
\r
88 + /* no zero length tag, leading whitespace or leading - */
\r
89 + if (*tag == '\0' || isspace ((unsigned char) *tag) || *tag == '-')
\r
92 + /* no whitespace except ' ', no trailing whitespace */
\r
93 + for (tag++; *tag; tag++) {
\r
94 + if (isspace ((unsigned char) *tag) && (*tag != ' ' || *(tag+1) == '\0'))
\r
102 notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
104 @@ -73,6 +89,10 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
107 if (argv[i][0] == '+') {
\r
108 + if (!tag_valid (argv[i] + 1)) {
\r
109 + fprintf (stderr, "Error: Invalid tag %s\n", argv[i] + 1);
\r
112 add_tags[add_tags_count++] = i;
\r
113 } else if (argv[i][0] == '-') {
\r
114 remove_tags[remove_tags_count++] = i;
\r