diff options
author | Jani Nikula <jani@nikula.org> | 2014-02-23 18:55:22 +0200 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-03-06 07:42:10 -0400 |
commit | e8ec38c25afefacff8c2adb6e4f9e53df9870746 (patch) | |
tree | b099b7a4deeb21db5d0a0e7e32b762fe23419352 /notmuch-new.c | |
parent | 07dd9d53cb7d92dc42ef697edb65e4c491b65928 (diff) |
cli: make sure notmuch new and insert don't add invalid tags
Check new.tags configuration values before doing anything, and bail
out on invalid values.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r-- | notmuch-new.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/notmuch-new.c b/notmuch-new.c index 8529fdd3..82acf695 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -19,6 +19,7 @@ */ #include "notmuch-client.h" +#include "tag-util.h" #include <unistd.h> @@ -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) |