diff --git a/src/lib-sieve/plugins/body/tst-body.c b/src/lib-sieve/plugins/body/tst-body.c index 8ef5660878ed78df6f738b7291ee0cfa02415fb3..3a9e058c6a07cf9fe099d3e4835e58bec310c53e 100644 --- a/src/lib-sieve/plugins/body/tst-body.c +++ b/src/lib-sieve/plugins/body/tst-body.c @@ -154,13 +154,10 @@ static bool tag_body_transform_validate * :content <content-types: string-list> */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) { return FALSE; } - if ( !sieve_validator_argument_activate(valdtr, cmd, *arg, FALSE) ) - return FALSE; - /* Assign tag parameters */ tag->parameters = *arg; *arg = sieve_ast_arguments_detach(*arg,1); diff --git a/src/lib-sieve/plugins/date/tst-date.c b/src/lib-sieve/plugins/date/tst-date.c index c2bbd65ccc8444c0bb10b6d407df1ffbc564c153..30d51903488f318e88297317ae0968b44cbda786 100644 --- a/src/lib-sieve/plugins/date/tst-date.c +++ b/src/lib-sieve/plugins/date/tst-date.c @@ -173,7 +173,7 @@ static bool tag_zone_validate * :zone <time-zone: string> */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) { return FALSE; } diff --git a/src/lib-sieve/plugins/enotify/cmd-notify.c b/src/lib-sieve/plugins/enotify/cmd-notify.c index e0f9afcaa06401e65461c67a91904b77d2054438..5b325f822ee0ee5955aa0a092ffa137546866f95 100644 --- a/src/lib-sieve/plugins/enotify/cmd-notify.c +++ b/src/lib-sieve/plugins/enotify/cmd-notify.c @@ -180,7 +180,8 @@ static bool cmd_notify_validate_string_tag * :from <string> * :message <string> */ - if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING) ) + if ( !sieve_validate_tag_parameter + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) return FALSE; if ( sieve_argument_is(tag, notify_from_tag) ) { @@ -213,7 +214,8 @@ static bool cmd_notify_validate_stringlist_tag /* Check syntax: * :options string-list */ - if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) + if ( !sieve_validate_tag_parameter + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) return FALSE; /* Assign context */ diff --git a/src/lib-sieve/plugins/imap4flags/tag-flags.c b/src/lib-sieve/plugins/imap4flags/tag-flags.c index 837baaa458739bfdee41857dd3fb5421465719d4..026faf0b6e7bc9de7952f572fd2d3775f6d481da 100644 --- a/src/lib-sieve/plugins/imap4flags/tag-flags.c +++ b/src/lib-sieve/plugins/imap4flags/tag-flags.c @@ -128,7 +128,7 @@ static bool tag_flags_validate * :flags <list-of-flags: string-list> */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) { return FALSE; } diff --git a/src/lib-sieve/plugins/notify/cmd-notify.c b/src/lib-sieve/plugins/notify/cmd-notify.c index 5592cce3caf94bed11489361cbfcb57cc38323d6..d7d31742f74c676fbb1476bd2e84c4fafeaba112 100644 --- a/src/lib-sieve/plugins/notify/cmd-notify.c +++ b/src/lib-sieve/plugins/notify/cmd-notify.c @@ -192,7 +192,8 @@ static bool cmd_notify_validate_string_tag * :method <string> * :message <string> */ - if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING) ) + if ( !sieve_validate_tag_parameter + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) return FALSE; if ( sieve_argument_is(tag, notify_method_tag) ) { @@ -231,7 +232,8 @@ static bool cmd_notify_validate_stringlist_tag /* Check syntax: * :options string-list */ - if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) + if ( !sieve_validate_tag_parameter + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) return FALSE; /* Assign context */ diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c index b56188446d1464a1b4ddf8f2c5b0a53be1fbcd08..255f4173dc2b939eaffab680634dd4c4f13e4f6d 100644 --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c @@ -242,7 +242,7 @@ static bool cmd_vacation_validate_number_tag * :days number */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_NUMBER) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) { return FALSE; } @@ -274,7 +274,7 @@ static bool cmd_vacation_validate_string_tag * :handle string */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) { return FALSE; } @@ -332,7 +332,7 @@ static bool cmd_vacation_validate_stringlist_tag * :addresses string-list */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) { return FALSE; } diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c index e385ec1186bf0b0136f3c5f89354b183929820a3..642e34e1b0aaa8cfe57a22c9e0037ef6410ed36c 100644 --- a/src/lib-sieve/sieve-validator.c +++ b/src/lib-sieve/sieve-validator.c @@ -803,14 +803,18 @@ bool sieve_validate_positional_argument bool sieve_validate_tag_parameter (struct sieve_validator *valdtr, struct sieve_command *cmd, struct sieve_ast_argument *tag, struct sieve_ast_argument *param, - enum sieve_ast_argument_type req_type) + const char *arg_name, unsigned int arg_pos, + enum sieve_ast_argument_type req_type, bool constant) { if ( param == NULL ) { + const char *position = ( arg_pos == 0 ? "" : + t_strdup_printf(" %d (%s)", arg_pos, arg_name) ); + sieve_argument_validate_error(valdtr, tag, - "the :%s tag for the %s %s requires %s as parameter, " - "but no more arguments were found", sieve_ast_argument_tag(tag), + "the :%s tag for the %s %s requires %s as parameter %s, " + "but no parameters were found", sieve_ast_argument_tag(tag), sieve_command_identifier(cmd), sieve_command_type_name(cmd), - sieve_ast_argument_type_name(req_type)); + sieve_ast_argument_type_name(req_type), position); return FALSE; } @@ -818,15 +822,19 @@ bool sieve_validate_tag_parameter (sieve_ast_argument_type(param) != SAAT_STRING || req_type != SAAT_STRING_LIST) ) { + const char *position = ( arg_pos == 0 ? "" : + t_strdup_printf(" %d (%s)", arg_pos, arg_name) ); + sieve_argument_validate_error(valdtr, param, - "the :%s tag for the %s %s requires %s as parameter, " + "the :%s tag for the %s %s requires %s as parameter%s, " "but %s was found", sieve_ast_argument_tag(tag), sieve_command_identifier(cmd), sieve_command_type_name(cmd), - sieve_ast_argument_type_name(req_type), sieve_ast_argument_name(param)); + sieve_ast_argument_type_name(req_type), position, + sieve_ast_argument_name(param)); return FALSE; } - if ( !sieve_validator_argument_activate(valdtr, cmd, param, FALSE) ) + if ( !sieve_validator_argument_activate(valdtr, cmd, param, constant) ) return FALSE; param->argument->id_code = tag->argument->id_code; diff --git a/src/lib-sieve/sieve-validator.h b/src/lib-sieve/sieve-validator.h index 5e34b25257fe4ef49a5682659fe3fca6b8589c3f..a1cf1fc8a718c4dd059806557bba75c21717d21d 100644 --- a/src/lib-sieve/sieve-validator.h +++ b/src/lib-sieve/sieve-validator.h @@ -114,7 +114,8 @@ bool sieve_validator_argument_activate bool sieve_validate_tag_parameter (struct sieve_validator *valdtr, struct sieve_command *cmd, struct sieve_ast_argument *tag, struct sieve_ast_argument *param, - enum sieve_ast_argument_type req_type); + const char *arg_name, unsigned int arg_pos, + enum sieve_ast_argument_type req_type, bool constant); /* * Extension support diff --git a/src/testsuite/cmd-test-message.c b/src/testsuite/cmd-test-message.c index 2cd19a8999c2d18ae60fbaea22ef078ea6eeec27..c1dbbcc86b3c13a6b28c868356d17d682a18e7bd 100644 --- a/src/testsuite/cmd-test-message.c +++ b/src/testsuite/cmd-test-message.c @@ -193,7 +193,7 @@ static bool cmd_test_message_validate_folder_tag * :folder string */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_STRING) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) { return FALSE; } diff --git a/src/testsuite/tst-test-error.c b/src/testsuite/tst-test-error.c index c393b622b7139d67c783e47f79e619545ecbd3e1..f5ae3b3c756c3ecb203e5079c1b0df7f185f9cb6 100644 --- a/src/testsuite/tst-test-error.c +++ b/src/testsuite/tst-test-error.c @@ -102,7 +102,7 @@ static bool tst_test_error_validate_index_tag * :index number */ if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, SAAT_NUMBER) ) { + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) { return FALSE; } diff --git a/src/testsuite/tst-test-result.c b/src/testsuite/tst-test-result.c index 0d4eededc680c6c3ab50f894a04d49d56b8725d0..d09e87df1738b70bd86065ba614589f5455a7836 100644 --- a/src/testsuite/tst-test-result.c +++ b/src/testsuite/tst-test-result.c @@ -107,7 +107,7 @@ static bool tst_test_result_validate_index_tag * :index number */ if ( !sieve_validate_tag_parameter - (validator, cmd, tag, *arg, SAAT_NUMBER) ) { + (validator, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) { return FALSE; }