From 60316c19c56fe736668cd55debb5dabe81265489 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 10 Aug 2008 20:44:56 +0200
Subject: [PATCH] Body: fixed default comparator and added testsuite test to
 prevent this in the future.

---
 src/lib-sieve/plugins/body/tst-body.c |  2 +-
 tests/extensions/body/basic.svtest    | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/lib-sieve/plugins/body/tst-body.c b/src/lib-sieve/plugins/body/tst-body.c
index b74107da1..1d58e30f1 100644
--- a/src/lib-sieve/plugins/body/tst-body.c
+++ b/src/lib-sieve/plugins/body/tst-body.c
@@ -305,7 +305,7 @@ static int ext_body_operation_execute
 	int ret = SIEVE_EXEC_OK;
 	int opt_code = 0;
 	int mret;
-	const struct sieve_comparator *cmp = &i_octet_comparator;
+	const struct sieve_comparator *cmp = &i_ascii_casemap_comparator;
 	const struct sieve_match_type *mtch = &is_match_type;
 	enum tst_body_transform transform;
 	struct sieve_coded_stringlist *key_list, *ctype_list = NULL;
diff --git a/tests/extensions/body/basic.svtest b/tests/extensions/body/basic.svtest
index 786ab5b2a..f9dab31da 100644
--- a/tests/extensions/body/basic.svtest
+++ b/tests/extensions/body/basic.svtest
@@ -12,6 +12,14 @@ Test!
 .
 ;
 
+/* Empty line
+ * 
+ *  RFC 5173: 
+ *    'The body test matches content in the body of an email message, that
+ *     is, anything following the first empty line after the header.  (The
+ *     empty line itself, if present, is not considered to be part of the
+ *     body.)'
+ */
 test "The empty line" {
 
 	if not body :raw :is text:
@@ -36,3 +44,22 @@ Test!
 		test_fail "body test matches nonsense";
 	}
 }
+
+/* Default comparator and match type
+ *
+ *  RFC 5173:
+ *    'The COMPARATOR and MATCH-TYPE keyword parameters are defined in
+ *     [SIEVE].  As specified in Sections 2.7.1 and 2.7.3 of [SIEVE], the
+ *     default COMPARATOR is "i;ascii-casemap" and the default MATCH-TYPE is
+ *     ":is".'
+ */
+
+test "Defaults" {
+	if anyof ( body :raw "Test", body :raw "*Test*" ) {
+		test_fail "default match type is not :is as is required";
+	}
+
+	if allof( not body :raw :contains "tesT", body :raw :contains "Test" ) {
+		test_fail "default comparator is not i;ascii-casemap as is required";
+	}
+}
-- 
GitLab