dovecot-2.2-pigeonhole: Merged changes from Pigeonhole v0.3.

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sun Mar 3 17:55:12 EET 2013


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/feb8fca97a0e
changeset: 1721:feb8fca97a0e
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun Mar 03 16:55:05 2013 +0100
description:
Merged changes from Pigeonhole v0.3.

diffstat:

 src/lib-sieve/cmd-redirect.c                             |   6 +-
 src/lib-sieve/edit-mail.c                                |   5 +-
 src/lib-sieve/plugins/editheader/ext-editheader-common.c |   2 +-
 src/lib-sieve/sieve-ast.c                                |   2 +-
 src/lib-sieve/sieve-binary.c                             |   2 +-
 src/lib-sieve/sieve-error.c                              |   4 +-
 src/lib-sieve/sieve-validator.c                          |   2 +-
 src/managesieve-login/client-authenticate.c              |   2 +-
 src/plugins/lda-sieve/lda-sieve-plugin.c                 |  57 +++++++++-----
 tests/extensions/editheader/alternating.svtest           |  59 ++++++++++++++++
 10 files changed, 110 insertions(+), 31 deletions(-)

diffs (288 lines):

diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/cmd-redirect.c	Sun Mar 03 16:55:05 2013 +0100
@@ -376,16 +376,18 @@
 		action->mail : sieve_message_get_mail(aenv->msgctx) );
 	const struct sieve_message_data *msgdata = aenv->msgdata;
 	const struct sieve_script_env *senv = aenv->scriptenv;
+	const char *orig_recipient = sieve_message_get_orig_recipient(aenv->msgctx);
 	const char *dupeid;
 
 	/* Prevent mail loops if possible */
-	dupeid = msgdata->id == NULL ?
-		NULL : t_strdup_printf("%s-%s", msgdata->id, ctx->to_address);
+	dupeid = msgdata->id == NULL ? NULL : t_strdup_printf
+		("%s-%s-%s", msgdata->id, orig_recipient, ctx->to_address);
 	if (dupeid != NULL) {
 		/* Check whether we've seen this message before */
 		if (sieve_action_duplicate_check(senv, dupeid, strlen(dupeid))) {
 			sieve_result_global_log(aenv, "discarded duplicate forward to <%s>",
 				str_sanitize(ctx->to_address, 128));
+			*keep = FALSE;
 			return TRUE;
 		}
 	}
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/edit-mail.c
--- a/src/lib-sieve/edit-mail.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/edit-mail.c	Sun Mar 03 16:55:05 2013 +0100
@@ -322,6 +322,7 @@
 				(&edmail_new->header_fields_head, &edmail_new->header_fields_tail,
 					field_idx_new);
 
+			field_idx_new->header->count++;
 			if ( field_idx->header->first == field_idx )
 				field_idx_new->header->first = field_idx_new;
 			if ( field_idx->header->last == field_idx )
@@ -658,9 +659,11 @@
 	/* Insert header field index items in main list */
 	if ( head != NULL && tail != NULL ) {
 		if ( edmail->header_fields_appended != NULL ) {
-			if ( edmail->header_fields_appended->prev != NULL ) {
+			if ( edmail->header_fields_head != edmail->header_fields_appended ) {
 				edmail->header_fields_appended->prev->next = head;
 				head->prev = edmail->header_fields_appended->prev;
+			} else {
+				edmail->header_fields_head = head;
 			}
 
 			tail->next = edmail->header_fields_appended;
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/plugins/editheader/ext-editheader-common.c
--- a/src/lib-sieve/plugins/editheader/ext-editheader-common.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/plugins/editheader/ext-editheader-common.c	Sun Mar 03 16:55:05 2013 +0100
@@ -64,7 +64,7 @@
 	}
 
 	T_BEGIN {
-		pool = pool_alloconly_create("editheader_config", 512);
+		pool = pool_alloconly_create("editheader_config", 1024);
 		ext_config = p_new(pool, struct ext_editheader_config, 1);
 		ext_config->pool = pool;
 		ext_config->max_header_size = EXT_EDITHEADER_DEFAULT_MAX_HEADER_SIZE;
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/sieve-ast.c
--- a/src/lib-sieve/sieve-ast.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/sieve-ast.c	Sun Mar 03 16:55:05 2013 +0100
@@ -59,7 +59,7 @@
 	struct sieve_ast *ast;
 	unsigned int ext_count;
 
-	pool = pool_alloconly_create("sieve_ast", 16384);
+	pool = pool_alloconly_create("sieve_ast", 32768);
 	ast = p_new(pool, struct sieve_ast, 1);
 	ast->pool = pool;
 	ast->refcount = 1;
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/sieve-binary.c
--- a/src/lib-sieve/sieve-binary.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/sieve-binary.c	Sun Mar 03 16:55:05 2013 +0100
@@ -43,7 +43,7 @@
 	const struct sieve_extension *const *ext_preloaded;
 	unsigned int i, ext_count;
 
-	pool = pool_alloconly_create("sieve_binary", 8192);
+	pool = pool_alloconly_create("sieve_binary", 16384);
 	sbin = p_new(pool, struct sieve_binary, 1);
 	sbin->pool = pool;
 	sbin->refcount = 1;
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/sieve-error.c
--- a/src/lib-sieve/sieve-error.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/sieve-error.c	Sun Mar 03 16:55:05 2013 +0100
@@ -1221,7 +1221,7 @@
 	if ( parent == NULL )
 		return NULL;
 
-	pool = pool_alloconly_create("sieve_prefix_error_handler", 256);
+	pool = pool_alloconly_create("sieve_prefix_error_handler", 512);
 	ehandler = p_new(pool, struct sieve_prefix_ehandler, 1);
 	sieve_error_handler_init_from_parent(&ehandler->handler, pool, parent);
 
@@ -1320,7 +1320,7 @@
 		return parent;
 	}
 
-	pool = pool_alloconly_create("sieve_varexpand_error_handler", 1024);
+	pool = pool_alloconly_create("sieve_varexpand_error_handler", 2048);
 	ehandler = p_new(pool, struct sieve_varexpand_ehandler, 1);
 	sieve_error_handler_init_from_parent(&ehandler->handler, pool, parent);
 
diff -r 44721c50833e -r feb8fca97a0e src/lib-sieve/sieve-validator.c
--- a/src/lib-sieve/sieve-validator.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/lib-sieve/sieve-validator.c	Sun Mar 03 16:55:05 2013 +0100
@@ -150,7 +150,7 @@
 	const struct sieve_extension *const *ext_preloaded;
 	unsigned int i, ext_count;
 
-	pool = pool_alloconly_create("sieve_validator", 8192);
+	pool = pool_alloconly_create("sieve_validator", 16384);
 	valdtr = p_new(pool, struct sieve_validator, 1);
 	valdtr->pool = pool;
 
diff -r 44721c50833e -r feb8fca97a0e src/managesieve-login/client-authenticate.c
--- a/src/managesieve-login/client-authenticate.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/managesieve-login/client-authenticate.c	Sun Mar 03 16:55:05 2013 +0100
@@ -243,7 +243,7 @@
 	}
 
 	if ( i_stream_next_line(client->input) == NULL )
-		msieve_client->skip_line = TRUE;
+		return 0;
 
 	return 1;
 }
diff -r 44721c50833e -r feb8fca97a0e src/plugins/lda-sieve/lda-sieve-plugin.c
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c	Sat Mar 02 23:27:13 2013 +0100
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c	Sun Mar 03 16:55:05 2013 +0100
@@ -221,7 +221,7 @@
 			(svinst, files[i], NULL, ehandler, &error);
 
 		if ( script == NULL ) {
-			switch ( errno ) {
+			switch ( error ) {
 			case SIEVE_ERROR_NOT_FOUND:
 				/* Shouldn't normally happen, but the script could have disappeared */
 				sieve_sys_warning
@@ -277,25 +277,34 @@
 		ehandler = srctx->master_ehandler;
 
 	if ( debug )
-		sieve_sys_debug(svinst, "opening script %s", sieve_script_location(script));
+		sieve_sys_debug(svinst, "loading script %s", sieve_script_location(script));
 
 	sieve_error_handler_reset(ehandler);
 
-	/* Open the sieve script */
+	/* Load or compile the sieve script */
 	if ( (sbin=sieve_open_script(script, ehandler, cpflags, error_r)) == NULL ) {
-		if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
+		switch ( *error_r ) {
+		/* Script not found */
+		case SIEVE_ERROR_NOT_FOUND:
 			if ( debug ) {
 				sieve_sys_debug(svinst, "script file %s is missing",
 					sieve_script_location(script));
 			}
-		} else if ( *error_r == SIEVE_ERROR_NOT_VALID &&
-			script == srctx->user_script && srctx->userlog != NULL ) {
-			sieve_sys_error(svinst,	"failed to open script %s "
-				"(view user logfile %s for more information)",
-				sieve_script_location(script), srctx->userlog);
-		} else {
+			break;
+		/* Compile failed */
+		case SIEVE_ERROR_NOT_VALID:
+			if (script == srctx->user_script && srctx->userlog != NULL ) {
+				sieve_sys_info(svinst, "failed to compile script %s "
+					"(view user logfile %s for more information)",
+					sieve_script_location(script), srctx->userlog);
+				break;
+			}
+			/* Fall through */
+		/* Something else */
+		default:
 			sieve_sys_error(svinst,	"failed to open script %s",
 				sieve_script_location(script));
+			break;
 		}
 
 		return NULL;
@@ -330,19 +339,25 @@
 	if ( (sbin=sieve_compile_script(script, ehandler,	cpflags, error_r))
 		== NULL ) {
 
-		if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
-			if ( debug )
+		switch ( *error_r ) {
+		case SIEVE_ERROR_NOT_FOUND:
+			if ( debug ) {
 				sieve_sys_debug(svinst, "script file %s is missing for re-compile",
 					sieve_script_location(script));
-		} else if ( *error_r == SIEVE_ERROR_NOT_VALID &&
-			script == srctx->user_script && srctx->userlog != NULL ) {
-			sieve_sys_error(svinst,
-				"failed to re-compile script %s "
-				"(view user logfile %s for more information)",
-				sieve_script_location(script), srctx->userlog);
-		} else {
-			sieve_sys_error(svinst,
-				"failed to re-compile script %s", sieve_script_location(script));
+			}
+			break;
+		case SIEVE_ERROR_NOT_VALID:
+			if ( script == srctx->user_script && srctx->userlog != NULL ) {
+				sieve_sys_info(svinst,
+					"failed to re-compile script %s "
+					"(view user logfile %s for more information)",
+					sieve_script_location(script), srctx->userlog);
+				break;
+			}
+			/* Fall through */
+		default:
+			sieve_sys_error(svinst,	"failed to open script %s for re-compile",
+				sieve_script_location(script));
 		}
 
 		return NULL;
diff -r 44721c50833e -r feb8fca97a0e tests/extensions/editheader/alternating.svtest
--- a/tests/extensions/editheader/alternating.svtest	Sat Mar 02 23:27:13 2013 +0100
+++ b/tests/extensions/editheader/alternating.svtest	Sun Mar 03 16:55:05 2013 +0100
@@ -120,3 +120,62 @@
 		test_fail "wrong content in redirected mail ";
 	}
 }
+
+test_result_reset;
+
+test_set "message" "${message}";
+test "Alternating - add :last; delete any" {
+	addheader :last "X-Some-Header" "Header content";
+
+	if not exists "x-some-header" {
+		test_fail "header not added";
+	}
+
+	if not header :is "x-some-header" "Header content" {
+		test_fail "wrong content added";
+	}
+
+	redirect "frop at example.com";
+
+	deleteheader "X-Some-Other-Header";
+
+	if not exists "x-some-header" {
+		test_fail "header somehow deleted";
+	}
+
+	fileinto :create "folder3";
+
+	if not test_result_execute {
+		test_fail "failed to execute result";
+	}
+
+	/* redirected message */
+
+	if not test_message :smtp 0 {
+		test_fail "message not redirected";
+	}
+
+	if not exists "x-some-header" {
+		test_fail "added header not in redirected mail";
+	}
+
+	if not header :is "x-some-header" "Header content" {
+		test_fail "wrong content in redirected mail ";
+	}
+
+	/* stored message message */
+
+	if not test_message :folder "folder3" 0 {
+		test_fail "message not stored";
+	}
+
+	if not exists "x-some-header" {
+		test_fail "added header lost in stored mail";
+	}
+
+	if not header :is "x-some-header" "Header content" {
+		test_fail "wrong content in stored mail ";
+	}
+
+}
+


More information about the dovecot-cvs mailing list