From df66a8ed96a268b9eae101631dc048cdae0e60bb Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sat, 23 Feb 2008 23:59:25 +0100
Subject: [PATCH] Variables: fixed bug in string-list containing variables.

---
 .../plugins/variables/ext-variables-common.c  | 32 +++++++++++++------
 .../plugins/variables/variables.sieve         | 16 ++++++++--
 src/lib-sieve/sieve-code.c                    |  6 ++--
 3 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.c b/src/lib-sieve/plugins/variables/ext-variables-common.c
index c2a7a625a..b2e84b628 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c
@@ -548,10 +548,14 @@ static bool opr_variable_read_value
 	if ( storage == NULL ) return FALSE;
 		
 	if (sieve_binary_read_integer(renv->sbin, address, &index) ) {
-		sieve_variable_get(storage, index, str);
+		/* Parameter str can be NULL if we are requested to only skip and not 
+		 * actually read the argument.
+	 	*/
+		if ( str != NULL ) {
+			sieve_variable_get(storage, index, str);
 		
-		if ( *str == NULL ) *str = t_str_new(0);
-
+			if ( *str == NULL ) *str = t_str_new(0);
+		}
 		return TRUE;
 	}
 	
@@ -636,14 +640,24 @@ static bool opr_variable_string_read
 	if ( !sieve_binary_read_integer(renv->sbin, address, &elements) )
 		return FALSE;
 
-	*str = t_str_new(128);
-	for ( i = 0; i < (unsigned int) elements; i++ ) {
-		string_t *strelm;
+	/* Parameter str can be NULL if we are requested to only skip and not 
+	 * actually read the argument.
+	 */
+	if ( str == NULL ) {
+		for ( i = 0; i < (unsigned int) elements; i++ ) {		
+			if ( !sieve_opr_string_read(renv, address, NULL) ) 
+				return FALSE;
+		}
+	} else {
+		*str = t_str_new(128);
+		for ( i = 0; i < (unsigned int) elements; i++ ) {
+			string_t *strelm;
 		
-		if ( !sieve_opr_string_read(renv, address, &strelm) ) 
-			return FALSE;
+			if ( !sieve_opr_string_read(renv, address, &strelm) ) 
+				return FALSE;
 		
-		str_append_str(*str, strelm);
+			str_append_str(*str, strelm);
+		}
 	}
 
 	return TRUE;
diff --git a/src/lib-sieve/plugins/variables/variables.sieve b/src/lib-sieve/plugins/variables/variables.sieve
index 7f255241d..8510e4c03 100644
--- a/src/lib-sieve/plugins/variables/variables.sieve
+++ b/src/lib-sieve/plugins/variables/variables.sieve
@@ -21,8 +21,18 @@ fileinto "${frop}";
 fileinto "LEN-${len_frop}";
 fileinto "${quote_friep}";
 
-if string "${foo}" "foosome" {
-	keep;
-} elsif string :comparator "i;ascii-casemap" "${foo}" "foosome" {
+set "header" "subject";
+set :lower "hvalue" "moNey";
+set :lower "speed" "very fast";
+
+if header :contains "${header}" ["${hvalue}"] {
+	fileinto "Oeh, het werkt.";
+} 
+
+if header :contains "${header}" ["${hvalue} ${speed}"] {
+	fileinto "Oeh, dit werkt ook.";
+} 
+
+if header :comparator "i;ascii-casemap" "${foo}" "foosome" {
 	fileinto "CASE";
 }
diff --git a/src/lib-sieve/sieve-code.c b/src/lib-sieve/sieve-code.c
index dd9c7edec..10ddb6b04 100644
--- a/src/lib-sieve/sieve-code.c
+++ b/src/lib-sieve/sieve-code.c
@@ -540,9 +540,9 @@ struct sieve_coded_stringlist *sieve_opr_stringlist_read
 		const struct sieve_opr_string_interface *intf = 
 			(const struct sieve_opr_string_interface *) operand->interface;
 		
-  	if ( intf->read == NULL || !intf->read(renv, address, NULL) ) {
-  		return NULL;
-  	}
+		if ( intf->read == NULL || !intf->read(renv, address, NULL) ) {
+			return NULL;
+		}
   
 		return sieve_coded_stringlist_create(renv, start, 1, *address); 
 	}	
-- 
GitLab