|
|
386c00 |
|
|
|
386c00 |
# HG changeset patch
|
|
|
386c00 |
# User Stephan Bosch <stephan@rename-it.nl>
|
|
|
386c00 |
# Date 1419976864 -3600
|
|
|
386c00 |
# Node ID b6c55ac6460d6e9d7c8784d7e0b9c0bd5ce160aa
|
|
|
386c00 |
# Parent c9698bc1751a70a808c286d43728e79b35c6ade7
|
|
|
386c00 |
lib-sieve: Fixed crash in validation of the string parameter of the comparator tag.
|
|
|
386c00 |
It couldn't handle a missing parameter (which also means missing arguments of the test itself in most cases).
|
|
|
386c00 |
This is fixed by using the sieve_validate_tag_parameter() utility function.
|
|
|
386c00 |
Testsuite is also extended.
|
|
|
386c00 |
|
|
|
386c00 |
diff -r c9698bc1751a -r b6c55ac6460d src/lib-sieve/sieve-comparators.c
|
|
|
386c00 |
--- a/src/lib-sieve/sieve-comparators.c Tue Dec 30 22:57:07 2014 +0100
|
|
|
386c00 |
+++ b/src/lib-sieve/sieve-comparators.c Tue Dec 30 23:01:04 2014 +0100
|
|
|
386c00 |
@@ -140,16 +140,11 @@
|
|
|
386c00 |
/* Check syntax:
|
|
|
386c00 |
* ":comparator" <comparator-name: string>
|
|
|
386c00 |
*/
|
|
|
386c00 |
- if ( (*arg)->type != SAAT_STRING ) {
|
|
|
386c00 |
- sieve_argument_validate_error(valdtr, *arg,
|
|
|
386c00 |
- ":comparator tag requires one string argument, but %s was found",
|
|
|
386c00 |
- sieve_ast_argument_name(*arg) );
|
|
|
386c00 |
+ if ( !sieve_validate_tag_parameter
|
|
|
386c00 |
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) {
|
|
|
386c00 |
return FALSE;
|
|
|
386c00 |
}
|
|
|
386c00 |
|
|
|
386c00 |
- if ( !sieve_validator_argument_activate(valdtr, cmd, *arg, FALSE) )
|
|
|
386c00 |
- return FALSE;
|
|
|
386c00 |
-
|
|
|
386c00 |
/* FIXME: We can currently only handle string literal argument, so
|
|
|
386c00 |
* variables are not allowed.
|
|
|
386c00 |
*/
|
|
|
386c00 |
diff -r c9698bc1751a -r b6c55ac6460d tests/compile/errors.svtest
|
|
|
386c00 |
--- a/tests/compile/errors.svtest Tue Dec 30 22:57:07 2014 +0100
|
|
|
386c00 |
+++ b/tests/compile/errors.svtest Tue Dec 30 23:01:04 2014 +0100
|
|
|
386c00 |
@@ -243,6 +243,20 @@
|
|
|
386c00 |
}
|
|
|
386c00 |
|
|
|
386c00 |
/*
|
|
|
386c00 |
+ * COMPARATOR errors
|
|
|
386c00 |
+ */
|
|
|
386c00 |
+
|
|
|
386c00 |
+test "COMPARATOR errors (FIXME: count only)" {
|
|
|
386c00 |
+ if test_script_compile "errors/comparator.sieve" {
|
|
|
386c00 |
+ test_fail "compile should have failed.";
|
|
|
386c00 |
+ }
|
|
|
386c00 |
+
|
|
|
386c00 |
+ if not test_error :count "eq" :comparator "i;ascii-numeric" "6" {
|
|
|
386c00 |
+ test_fail "wrong number of errors reported";
|
|
|
386c00 |
+ }
|
|
|
386c00 |
+}
|
|
|
386c00 |
+
|
|
|
386c00 |
+/*
|
|
|
386c00 |
* ADDRESS-PART errors
|
|
|
386c00 |
*/
|
|
|
386c00 |
|
|
|
386c00 |
diff -r c9698bc1751a -r b6c55ac6460d tests/compile/errors/comparator.sieve
|
|
|
386c00 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
|
386c00 |
+++ b/tests/compile/errors/comparator.sieve Tue Dec 30 23:01:04 2014 +0100
|
|
|
386c00 |
@@ -0,0 +1,21 @@
|
|
|
386c00 |
+/*
|
|
|
386c00 |
+ * Address part errors
|
|
|
386c00 |
+ *
|
|
|
386c00 |
+ * Total errors: 5 (+1 = 6)
|
|
|
386c00 |
+ */
|
|
|
386c00 |
+
|
|
|
386c00 |
+# 1: No argument
|
|
|
386c00 |
+if address :comparator { }
|
|
|
386c00 |
+
|
|
|
386c00 |
+# 2: Number argument
|
|
|
386c00 |
+if address :comparator 1 "from" "frop" { }
|
|
|
386c00 |
+
|
|
|
386c00 |
+# 3: String list argument
|
|
|
386c00 |
+if address :comparator ["a", "b"] "from" "frop" { }
|
|
|
386c00 |
+
|
|
|
386c00 |
+# 4: Unknown tag
|
|
|
386c00 |
+if address :comparator :frop "from" "frop" { }
|
|
|
386c00 |
+
|
|
|
386c00 |
+# 5: Known tag
|
|
|
386c00 |
+if address :comparator :all "from" "frop" { }
|
|
|
386c00 |
+
|
|
|
386c00 |
|
|
|
386c00 |
|