dovecot-2.2-pigeonhole: lib-sieve: Made validator resolve all ta...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Wed Nov 12 21:11:21 UTC 2014


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/c8e8321f2891
changeset: 1959:c8e8321f2891
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Wed Nov 12 22:09:44 2014 +0100
description:
lib-sieve: Made validator resolve all tagged command arguments before validating them.
This is needed so that argument validation functions can reliably verify other arguments at arbitrary positions.

diffstat:

 src/lib-sieve/sieve-validator.c |  34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diffs (57 lines):

diff -r be2f902b41fb -r c8e8321f2891 src/lib-sieve/sieve-validator.c
--- a/src/lib-sieve/sieve-validator.c	Sun Nov 02 18:35:34 2014 +0100
+++ b/src/lib-sieve/sieve-validator.c	Wed Nov 12 22:09:44 2014 +0100
@@ -890,16 +890,19 @@
 	struct sieve_ast_argument *arg;
 	struct sieve_command_registration *cmd_reg = cmd->reg;
 
-	/* Validate any tags that might be present */
+	/* Resolve tagged arguments */
 	arg = sieve_ast_argument_first(cmd->ast_node);
+	while ( arg != NULL ) {
+		void *arg_data = NULL;
+		struct sieve_tag_registration *tag_reg;
+		const struct sieve_argument_def *tag_def;
 
-	/* Visit tagged and optional arguments */
-	while ( arg != NULL && sieve_ast_argument_type(arg) == SAAT_TAG ) {
-		struct sieve_ast_argument *parg;
-		void *arg_data = NULL;
-		struct sieve_tag_registration *tag_reg =
-			sieve_validator_command_tag_get(valdtr, cmd, arg, &arg_data);
-		const struct sieve_argument_def *tag_def;
+		if (sieve_ast_argument_type(arg) != SAAT_TAG) {
+			arg = sieve_ast_argument_next(arg);
+			continue;
+		}
+
+		tag_reg = sieve_validator_command_tag_get(valdtr, cmd, arg, &arg_data);
 
 		if ( tag_reg == NULL ) {
 			sieve_argument_validate_error(valdtr, arg,
@@ -923,13 +926,22 @@
 			(arg->ast, tag_def, tag_reg->ext, tag_reg->id_code);
 		arg->argument->data = arg_data;
 
+		arg = sieve_ast_argument_next(arg);
+	}
+
+	/* Validate tagged arguments */
+	arg = sieve_ast_argument_first(cmd->ast_node);
+	while ( arg != NULL && sieve_ast_argument_type(arg) == SAAT_TAG) {
+		const struct sieve_argument_def *tag_def = arg->argument->def;
+		struct sieve_ast_argument *parg;
+
 		/* Scan backwards for any duplicates */
 		parg = sieve_ast_argument_prev(arg);
 		while ( parg != NULL ) {
 			if ( (sieve_ast_argument_type(parg) == SAAT_TAG &&
-					parg->argument->def == tag_reg->tag_def)
-				|| (tag_reg->id_code > 0 && parg->argument != NULL &&
-					parg->argument->id_code == tag_reg->id_code) )
+					parg->argument->def == tag_def)
+				|| (arg->argument->id_code > 0 && parg->argument != NULL &&
+					parg->argument->id_code == arg->argument->id_code) )
 			{
 				const char *tag_id = sieve_ast_argument_tag(arg);
 				const char *tag_desc =


More information about the dovecot-cvs mailing list