From: Tomi Ollila <tomi.ollila@iki.fi>
To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] tag: Disallow adding malformed tags to messages
Date: Sat, 27 Oct 2012 00:17:43 +0300 [thread overview]
Message-ID: <m2haphue4o.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <1351284853-24809-1-git-send-email-amdragon@mit.edu>
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
next prev parent reply other threads:[~2012-10-26 21:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 20:54 [PATCH 1/2] tag: Disallow adding malformed tags to messages Austin Clements
2012-10-26 20:54 ` [PATCH 2/2] News for restrictions on tag names Austin Clements
2012-10-26 21:17 ` Tomi Ollila [this message]
2012-10-27 5:16 ` [PATCH 1/2] tag: Disallow adding malformed tags to messages Ethan Glasser-Camp
2012-10-27 12:45 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2haphue4o.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=amdragon@MIT.EDU \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).