Re: [PATCH 1/2] tag: Disallow adding malformed tags to messages
authorTomi Ollila <tomi.ollila@iki.fi>
Fri, 26 Oct 2012 21:17:43 +0000 (00:17 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:04 +0000 (09:50 -0800)
12/79290849ca2fba2e848059b9e68972f102c92f [new file with mode: 0644]

diff --git a/12/79290849ca2fba2e848059b9e68972f102c92f b/12/79290849ca2fba2e848059b9e68972f102c92f
new file mode 100644 (file)
index 0000000..ab1f6a0
--- /dev/null
@@ -0,0 +1,114 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D0020431FAF\r
+       for <notmuch@notmuchmail.org>; Fri, 26 Oct 2012 14:17:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id t0zfboOm9qYh for <notmuch@notmuchmail.org>;\r
+       Fri, 26 Oct 2012 14:17:41 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 53F3E431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 26 Oct 2012 14:17:41 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 72792100045;\r
+       Sat, 27 Oct 2012 00:17:43 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/2] tag: Disallow adding malformed tags to messages\r
+In-Reply-To: <1351284853-24809-1-git-send-email-amdragon@mit.edu>\r
+References: <1351284853-24809-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+59~gf9031cd (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 27 Oct 2012 00:17:43 +0300\r
+Message-ID: <m2haphue4o.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 26 Oct 2012 21:17:42 -0000\r
+\r
+On Fri, Oct 26 2012, Austin Clements wrote:\r
+\r
+> This disallows adding empty tags, since nothing but confusion follows\r
+> in their wake, and disallows adding tags that begin with "-" because\r
+> they are also confusing, the tag "-" is impossible to remove using the\r
+> CLI, and because the syntax for removing such tags conflicts with long\r
+> argument syntax.\r
+>\r
+> This does not place any restrictions on what tags can be removed, as\r
+> that would make it difficult for people who have the misfortune of\r
+> already having malformed tags to remove these tags.\r
+> ---\r
+\r
+LGTM (NEWS too)\r
+\r
+Tomi\r
+\r
+\r
+>  notmuch-tag.c |   11 +++++++++++\r
+>  test/tagging  |    4 ++++\r
+>  2 files changed, 15 insertions(+)\r
+>\r
+> diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+> index 7d18639..d15f1ed 100644\r
+> --- a/notmuch-tag.c\r
+> +++ b/notmuch-tag.c\r
+> @@ -203,6 +203,17 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
+>          break;\r
+>      }\r
+>      if (argv[i][0] == '+' || argv[i][0] == '-') {\r
+> +        if (argv[i][0] == '+' && argv[i][1] == '\0') {\r
+> +            fprintf(stderr, "Error: tag names cannot be empty.\n");\r
+> +            return 1;\r
+> +        }\r
+> +        if (argv[i][0] == '+' && argv[i][1] == '-') {\r
+> +            /* This disallows adding the non-removable tag "-" and\r
+> +             * enables notmuch tag to take long options in the\r
+> +             * future. */\r
+> +            fprintf(stderr, "Error: tag names must not start with '-'.\n");\r
+> +            return 1;\r
+> +        }\r
+>          tag_ops[tag_ops_count].tag = argv[i] + 1;\r
+>          tag_ops[tag_ops_count].remove = (argv[i][0] == '-');\r
+>          tag_ops_count++;\r
+> diff --git a/test/tagging b/test/tagging\r
+> index e4782ed..980ff92 100755\r
+> --- a/test/tagging\r
+> +++ b/test/tagging\r
+> @@ -46,4 +46,8 @@ test_expect_equal "$output" "\\r
+>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)\r
+>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)"\r
+>  \r
+> +test_expect_code 1 "Empty tag names" 'notmuch tag + One'\r
+> +\r
+> +test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'\r
+> +\r
+>  test_done\r
+> -- \r
+> 1.7.10\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r