dovecot-2.0-pigeonhole: Fixed FIXME: Date test now reports warni...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Mon Aug 30 04:13:37 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/66cf3c948718
changeset: 1399:66cf3c948718
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Mon Aug 30 03:13:29 2010 +0200
description:
Fixed FIXME: Date test now reports warning when invalid zone argument is encountered at runtime.

diffstat:

 src/lib-sieve/plugins/date/tst-date.c |  17 +++++++++++------
 src/lib-sieve/sieve-code.c            |   4 ++--
 src/lib-sieve/sieve-code.h            |   6 ++++++
 3 files changed, 19 insertions(+), 8 deletions(-)

diffs (93 lines):

diff -r 6a7edb7c3f0d -r 66cf3c948718 src/lib-sieve/plugins/date/tst-date.c
--- a/src/lib-sieve/plugins/date/tst-date.c	Mon Aug 30 02:52:49 2010 +0200
+++ b/src/lib-sieve/plugins/date/tst-date.c	Mon Aug 30 03:13:29 2010 +0200
@@ -390,7 +390,7 @@
 	string_t *date_part = NULL, *zone = NULL;
 	struct sieve_stringlist *hdr_list = NULL, *hdr_value_list;
 	struct sieve_stringlist *value_list, *key_list;
-	bool zone_specified = FALSE;
+	bool zone_specified = FALSE, zone_literal = TRUE;
 	int time_zone;
 	int match, ret;
 	
@@ -414,6 +414,8 @@
 				if ( (ret=sieve_opr_string_read_data
 					(renv, &oprnd, address, "zone", &zone)) <= 0 )
 					return ret;
+
+				zone_literal = sieve_operand_is_string_literal(&oprnd);
 			}
 
 			zone_specified = TRUE;
@@ -435,26 +437,29 @@
 	if ( (ret=sieve_opr_string_read(renv, address, "date-part", &date_part)) 
 		<= 0 )
 		return ret;
-		
+
 	/* Read key-list */
 	if ( (ret=sieve_opr_stringlist_read(renv, address, "key-list", &key_list))
 		<= 0 )
 		return ret;
-	
+
 	/* Determine what time zone to use in the result */
 	if ( !zone_specified ) {
 		time_zone = EXT_DATE_TIMEZONE_LOCAL;
 	} else if ( zone == NULL ) {
 		time_zone = EXT_DATE_TIMEZONE_ORIGINAL;
 	} else if ( !ext_date_parse_timezone(str_c(zone), &time_zone) ) {
-		/* FIXME: warn about parse failures */
+		if ( !zone_literal )
+			sieve_runtime_warning(renv, NULL, 
+				"specified :zone argument '%s' is not a valid timezone "
+				"(using local zone)", str_sanitize(str_c(zone), 40));
 		time_zone = EXT_DATE_TIMEZONE_LOCAL;
 	}
 
-	/* 
+	/*
 	 * Perform test 
 	 */
-	
+
 	if ( sieve_operation_is(op, date_operation) ) {
 	
 		sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, "date test");
diff -r 6a7edb7c3f0d -r 66cf3c948718 src/lib-sieve/sieve-code.c
--- a/src/lib-sieve/sieve-code.c	Mon Aug 30 02:52:49 2010 +0200
+++ b/src/lib-sieve/sieve-code.c	Mon Aug 30 03:13:29 2010 +0200
@@ -546,7 +546,7 @@
 		return FALSE;
 	}
 
-	*literal_r = sieve_operand_is(&operand, string_operand);	
+	*literal_r = sieve_operand_is_string_literal(&operand);
 
 	return sieve_opr_string_dump_data(denv, &operand, address, field_name);
 } 
@@ -601,7 +601,7 @@
 		<= 0 )
 		return ret;
 
-	*literal_r = sieve_operand_is(&operand, string_operand);
+	*literal_r = sieve_operand_is_string_literal(&operand);
 
 	return sieve_opr_string_read_data(renv, &operand, address, field_name, str_r);
 }
diff -r 6a7edb7c3f0d -r 66cf3c948718 src/lib-sieve/sieve-code.h
--- a/src/lib-sieve/sieve-code.h	Mon Aug 30 02:52:49 2010 +0200
+++ b/src/lib-sieve/sieve-code.h	Mon Aug 30 03:13:29 2010 +0200
@@ -231,6 +231,12 @@
 		operand->def->class == &string_class );
 }
 
+static inline bool sieve_operand_is_string_literal
+(const struct sieve_operand *operand)
+{
+	return ( operand != NULL && sieve_operand_is(operand, string_operand) );
+}
+
 /* String list */
 
 void sieve_opr_stringlist_emit_start


More information about the dovecot-cvs mailing list