dovecot-2.2-pigeonhole: lib-sieve: util: Fixed RFC5322 header fo...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Fri Jul 24 21:26:06 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/e97b533c0be6
changeset: 2081:e97b533c0be6
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Fri Jul 24 23:24:33 2015 +0200
description:
lib-sieve: util: Fixed RFC5322 header folding.

diffstat:

 src/lib-sieve/util/rfc2822.c             |  30 +++++++----
 tests/extensions/vacation/message.svtest |  78 +++++++++++++++++++++++++++++++-
 2 files changed, 96 insertions(+), 12 deletions(-)

diffs (158 lines):

diff -r 1d5a1d4f7bb7 -r e97b533c0be6 src/lib-sieve/util/rfc2822.c
--- a/src/lib-sieve/util/rfc2822.c	Mon Jul 06 23:47:05 2015 +0200
+++ b/src/lib-sieve/util/rfc2822.c	Fri Jul 24 23:24:33 2015 +0200
@@ -158,34 +158,42 @@
 		if ( *bp == '\0' ) break;
 
 		/* Existing newline ? */
-		if ( nlp != NULL ) {
+		if ( nlp != NULL ) {			
 			/* Replace any sort of newline for consistency */
 			while ( *bp == '\r' || *bp == '\n' )
 				bp++;
 
 			str_append_n(header, sp, nlp-sp);
 
-			if ( *bp != '\0' && *bp != ' ' && *bp != '\t' ) {
-				if ( crlf )
-					str_append_n(header, "\r\n\t", 3);
-				else
-					str_append_n(header, "\n\t", 2);
-			} else {
-				if ( crlf )
-					str_append_n(header, "\r\n", 2);
-				else
-					str_append_n(header, "\n", 1);
+			if ( crlf )
+				str_append_n(header, "\r\n", 2);
+			else
+				str_append_n(header, "\n", 1);
+
+			if ( *bp != '\0' && (*bp == ' ' || *bp == '\t') ) {
+				/* Continued line; replace leading whitespace with single TAB */
+				str_append_c(header, '\t');
+				while ( *bp == ' ' || *bp == '\t' )
+					bp++;
 			}
 
 			sp = bp;
 		} else {
 			/* Insert newline at last whitespace within the max_line limit */
 			str_append_n(header, sp, wp-sp);
+
+			/* Force continued line; drop any existing whitespace */
+			while ( *wp == ' ' || *wp == '\t' )
+				wp++;
+
 			if ( crlf )
 				str_append_n(header, "\r\n", 2);
 			else
 				str_append_n(header, "\n", 1);
 
+			/* Insert single TAB instead of the original whitespace */
+			str_append_c(header, '\t');
+
 			sp = wp;
 		}
 
diff -r 1d5a1d4f7bb7 -r e97b533c0be6 tests/extensions/vacation/message.svtest
--- a/tests/extensions/vacation/message.svtest	Mon Jul 06 23:47:05 2015 +0200
+++ b/tests/extensions/vacation/message.svtest	Fri Jul 24 23:24:33 2015 +0200
@@ -49,15 +49,92 @@
 }
 
 /*
+ * References - long IDs
+ */
+
+test_result_reset;
+
+test_set "message" text:
+Date: Fri, 21 Jul 2013 10:34:14 +0200 (CEST)
+From: Test <user1 at dovetest.example.org>
+To: User Two <user2 at dovetest.example.org>
+Message-ID: <1294794880.187.416268f9-b907-4566-af85-c77155eb7d96.farce at fresno.local>
+In-Reply-To: <1813483923.1202.aa78bea5-b5bc-4ab9-a64f-af96521e3af3.frobnitzm at dev.frobnitzm.com>
+References: <d660a7d1-43c9-47ea-a59a-0b29abc861d2 at frop.xi.local>
+ <500510465.1519.d2ac1c0c-08f7-44fd-97aa-dd711411aacf.frobnitzm at dev.frobnitzm.com>
+ <717028309.1200.aa78bea5-b5bc-4ab9-a64f-af96521e3af3.frobnitzm at dev.frobnitzm.com>
+ <1813483923.1202.aa78bea5-b5bc-4ab9-a64f-af96521e3af3.frobnitzm at dev.frobnitzm.com>
+Subject: Re: Fwd: My mail
+MIME-Version: 1.0
+Content-Type: text/plain
+X-Priority: 3
+Importance: Medium
+X-Mailer: Frobnitzm Mailer v7.8.0-Rev0
+
+Frop
+.
+;
+
+test "References - long IDs" {
+	vacation "I am not in today!";
+
+	if not test_result_execute {
+		test_fail "execution of result failed";
+	}
+
+	test_message :smtp 0;
+
+	if not header :contains "references" "1294794880.187.416268f9-b907-4566-af85-c77155eb7d96.farce at fresno.local" {
+		test_fail "references header does not contain new id";
+	}
+
+	if anyof (
+		not header :contains "references" "d660a7d1-43c9-47ea-a59a-0b29abc861d2 at frop.xi.local",
+		not header :contains "references" "500510465.1519.d2ac1c0c-08f7-44fd-97aa-dd711411aacf.frobnitzm at dev.frobnitzm.com",
+		not header :contains "references" "717028309.1200.aa78bea5-b5bc-4ab9-a64f-af96521e3af3.frobnitzm at dev.frobnitzm.com",
+		not header :contains "references" "1813483923.1202.aa78bea5-b5bc-4ab9-a64f-af96521e3af3.frobnitzm at dev.frobnitzm.com"
+		) {
+		test_fail "references header does not contain all existing ids";
+	}
+
+	if header :contains "references" "hutsefluts" {
+		test_fail "references header contains nonsense";
+	}
+}
+
+/*
  * In-Reply-To
  */
 
+test_result_reset;
+
+test_set "message" text:
+From: stephan at example.org
+Subject: frop
+References: <1234 at local.machine.example> <3456 at example.net>
+ <435444 at ttms.example.org> <4223 at froop.example.net> <m345444444 at message-id.exp>
+Message-ID: <432df324 at example.org>
+To: nico at frop.example.org
+
+Frop
+.
+;
+
 test "In-Reply-To" {
+	vacation "I am not in today!";
+
+	if not test_result_execute {
+		test_fail "execution of result failed";
+	}
+
+	test_message :smtp 0;
+
 	if not header :is "in-reply-to" "<432df324 at example.org>" {
 		test_fail "in-reply-to header set incorrectly";
 	}
 }
 
+
 /*
  * Variables
  */
@@ -177,4 +254,3 @@
 		test_fail "envelope sender not set properly";
 	}
 }
-


More information about the dovecot-cvs mailing list