mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 07:11:41 +01:00
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.
This commit is contained in:
parent
07dd9d53cb
commit
e8ec38c25a
2 changed files with 22 additions and 1 deletions
|
@ -431,6 +431,15 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < new_tags_length; i++) {
|
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))
|
if (tag_op_list_append (tag_ops, new_tags[i], FALSE))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "notmuch-client.h"
|
#include "notmuch-client.h"
|
||||||
|
#include "tag-util.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -918,7 +919,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
_filename_node_t *f;
|
_filename_node_t *f;
|
||||||
int opt_index;
|
int opt_index;
|
||||||
int i;
|
unsigned int i;
|
||||||
notmuch_bool_t timer_is_active = FALSE;
|
notmuch_bool_t timer_is_active = FALSE;
|
||||||
notmuch_bool_t no_hooks = FALSE;
|
notmuch_bool_t no_hooks = FALSE;
|
||||||
notmuch_bool_t quiet = FALSE, verbose = 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);
|
add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
|
||||||
db_path = notmuch_config_get_database_path (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) {
|
if (!no_hooks) {
|
||||||
ret = notmuch_run_hook (db_path, "pre-new");
|
ret = notmuch_run_hook (db_path, "pre-new");
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Reference in a new issue