From: Jani Nikula Date: Sun, 23 Feb 2014 16:55:22 +0000 (+0200) Subject: [PATCH 2/3] cli: make sure notmuch new and insert don't add invalid tags X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=20ba70275171bfc935e50327a29970ea907991fa;p=notmuch-archives.git [PATCH 2/3] cli: make sure notmuch new and insert don't add invalid tags --- diff --git a/99/74d434cdc7457beadb089d9e0bfefa6fd7f1e0 b/99/74d434cdc7457beadb089d9e0bfefa6fd7f1e0 new file mode 100644 index 000000000..cc5dbec57 --- /dev/null +++ b/99/74d434cdc7457beadb089d9e0bfefa6fd7f1e0 @@ -0,0 +1,141 @@ +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 1589D431FD8 + for ; Sun, 23 Feb 2014 08:55:40 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 g0qgZNhmr3CF for ; + Sun, 23 Feb 2014 08:55:36 -0800 (PST) +Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com + [209.85.215.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A35BB431FCF + for ; Sun, 23 Feb 2014 08:55:34 -0800 (PST) +Received: by mail-ea0-f178.google.com with SMTP id a15so2666338eae.9 + for ; Sun, 23 Feb 2014 08:55:33 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references:in-reply-to:references; + bh=OB8U3rnc4byZ/F8Qgg13Ryn/sMPT1BP5kACnOYLMxmo=; + b=TcQBP6voiX/8XUj2cEofd4qpnuUF0apy+qYI2yx5gH++zh6kaWMYpznqjBtmsxcdeg + JbpBLCcpnx9TzlLwORi8hs1JJuamrTRzaFtuswgaeEkvO//n0hVwUfRNFt73FzjPYLQU + 4nq2jDEJMr+BtiUugd5S0RRB/4TXruwx3Nf5bsKETU+8vf9ylNFLTKZWvThhHdJpd1fr + JcJbiq9NM4ueEQxJ0pBpnXIm00PEcgrJUIeQs8seIz1sQDU2Tqd6NxD+cZGwIQil/SXr + xzigiAH1SzBcGgXTwG3G/NDoEN5x+IRnbtauAkHbgdfG/t9rNXjo9xO0VgrPZhIX48F/ + kjWw== +X-Gm-Message-State: + ALoCoQmwRBpooXm2DaU7ugFfRyTD7KhyNrQhJ5VcuVn8VYGrU5yg+4ZrqjtOmU/Oktjk2UaO0bJw +X-Received: by 10.14.193.193 with SMTP id k41mr19874863een.112.1393174532253; + Sun, 23 Feb 2014 08:55:32 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) by mx.google.com with ESMTPSA id + j41sm53050533eey.15.2014.02.23.08.55.30 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 23 Feb 2014 08:55:31 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org, + Rob Browning +Subject: [PATCH 2/3] cli: make sure notmuch new and insert don't add invalid + tags +Date: Sun, 23 Feb 2014 18:55:22 +0200 +Message-Id: + +X-Mailer: git-send-email 1.8.5.3 +In-Reply-To: +References: <87ha7qfto7.fsf@trouble.defaultvalue.org> + +In-Reply-To: +References: +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: Sun, 23 Feb 2014 16:55:40 -0000 + +Check new.tags configuration values before doing anything, and bail +out on invalid values. +--- + notmuch-insert.c | 9 +++++++++ + notmuch-new.c | 14 +++++++++++++- + 2 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/notmuch-insert.c b/notmuch-insert.c +index cd6de88f6891..6752fc8de255 100644 +--- a/notmuch-insert.c ++++ b/notmuch-insert.c +@@ -431,6 +431,15 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) + return EXIT_FAILURE; + } + for (i = 0; i < new_tags_length; i++) { ++ const char *error_msg; ++ ++ error_msg = illegal_tag (new_tags[i], FALSE); ++ if (error_msg) { ++ fprintf (stderr, "Error: tag '%s' in new.tags: %s\n", ++ new_tags[i], error_msg); ++ return EXIT_FAILURE; ++ } ++ + if (tag_op_list_append (tag_ops, new_tags[i], FALSE)) + return EXIT_FAILURE; + } +diff --git a/notmuch-new.c b/notmuch-new.c +index 8529fdd3eac7..82acf695353e 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -19,6 +19,7 @@ + */ + + #include "notmuch-client.h" ++#include "tag-util.h" + + #include + +@@ -918,7 +919,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) + struct sigaction action; + _filename_node_t *f; + int opt_index; +- int i; ++ unsigned int i; + notmuch_bool_t timer_is_active = FALSE; + notmuch_bool_t no_hooks = FALSE; + notmuch_bool_t quiet = FALSE, verbose = FALSE; +@@ -950,6 +951,17 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) + add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); + db_path = notmuch_config_get_database_path (config); + ++ for (i = 0; i < add_files_state.new_tags_length; i++) { ++ const char *error_msg; ++ ++ error_msg = illegal_tag (add_files_state.new_tags[i], FALSE); ++ if (error_msg) { ++ fprintf (stderr, "Error: tag '%s' in new.tags: %s\n", ++ add_files_state.new_tags[i], error_msg); ++ return EXIT_FAILURE; ++ } ++ } ++ + if (!no_hooks) { + ret = notmuch_run_hook (db_path, "pre-new"); + if (ret) +-- +1.8.5.3 +