dovecot-2.1-pigeonhole: lib-sieve: editheader extension: Fixed i...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Thu May 2 22:37:43 EEST 2013


details:   http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/0163c45094a3
changeset: 1686:0163c45094a3
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu May 02 21:37:36 2013 +0200
description:
lib-sieve: editheader extension: Fixed interaction with body extension.
Forgot to rewind mail stream before header parsing.
Wrapped mail stream is obtained long before parsing, so if it is used in the mean time, it must be rewound to the beginning.

diffstat:

 src/lib-sieve/edit-mail.c                           |   4 +++
 src/lib-sieve/plugins/editheader/cmd-deleteheader.c |  10 ++++++-
 tests/extensions/editheader/deleteheader.svtest     |  26 +++++++++++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diffs (75 lines):

diff -r bc2126771d00 -r 0163c45094a3 src/lib-sieve/edit-mail.c
--- a/src/lib-sieve/edit-mail.c	Sun Apr 07 05:12:57 2013 +0200
+++ b/src/lib-sieve/edit-mail.c	Thu May 02 21:37:36 2013 +0200
@@ -559,6 +559,7 @@
 
 	if ( edmail->headers_parsed ) return 1;
 
+	i_stream_seek(edmail->wrapped_stream, 0);
 	hparser = message_parse_header_init
 		(edmail->wrapped_stream, NULL, hparser_flags);
 
@@ -643,6 +644,9 @@
 	message_parse_header_deinit(&hparser);
 
 	if ( ret <= 0 ) {
+		/* blocking i/o required */
+		i_assert( ret != 0 );
+
 		/* Error; clean up */
 		current = head;
 		while ( current != NULL ) {
diff -r bc2126771d00 -r 0163c45094a3 src/lib-sieve/plugins/editheader/cmd-deleteheader.c
--- a/src/lib-sieve/plugins/editheader/cmd-deleteheader.c	Sun Apr 07 05:12:57 2013 +0200
+++ b/src/lib-sieve/plugins/editheader/cmd-deleteheader.c	Thu May 02 21:37:36 2013 +0200
@@ -531,9 +531,15 @@
 		/* Delete all occurences of header */
 		ret = edit_mail_header_delete(edmail, str_c(field_name), index);
 
-		if ( trace ) {
-			sieve_runtime_trace(renv, 0, "deleted %d headers", ret);
+		if ( ret < 0 ) {
+			sieve_runtime_warning(renv, NULL, "deleteheader action: "
+				"failed to delete occurences of header `%s' (this should not happen!)",
+				str_c(field_name));
+		} else if ( trace ) {
+			sieve_runtime_trace(renv, 0, "deleted %d occurences of header `%s'",
+				ret, str_c(field_name));
 		}
+
 	}
 
 	return SIEVE_EXEC_OK;
diff -r bc2126771d00 -r 0163c45094a3 tests/extensions/editheader/deleteheader.svtest
--- a/tests/extensions/editheader/deleteheader.svtest	Sun Apr 07 05:12:57 2013 +0200
+++ b/tests/extensions/editheader/deleteheader.svtest	Thu May 02 21:37:36 2013 +0200
@@ -962,3 +962,29 @@
 		test_fail "x-b header not deleted";
 	}
 }
+
+/*
+ * TEST: Interaction with body test
+ */
+
+test_set "message" text:
+From: stephan at example.org
+To: nico at frop.example.com
+Subject: Hoppa
+
+Text
+.
+;
+
+test "Interaction with body test" {
+	addheader "X-Frop" "frop";
+	
+	if body "!TEST!" {}
+
+	deleteheader "subject";
+
+	if exists "subject" {
+		test_fail "subject header not deleted";
+	}
+}
+


More information about the dovecot-cvs mailing list