diff --git a/src/lib-sieve/sieve-comparators.c b/src/lib-sieve/sieve-comparators.c index a66b28e2edf4611e1b0bf114113902bda0b38e25..c682031accb81ee5fa36a1dfadc5703cdf6d3523 100644 --- a/src/lib-sieve/sieve-comparators.c +++ b/src/lib-sieve/sieve-comparators.c @@ -140,16 +140,11 @@ static bool tag_comparator_validate /* Check syntax: * ":comparator" <comparator-name: string> */ - if ( (*arg)->type != SAAT_STRING ) { - sieve_argument_validate_error(valdtr, *arg, - ":comparator tag requires one string argument, but %s was found", - sieve_ast_argument_name(*arg) ); + if ( !sieve_validate_tag_parameter + (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) { return FALSE; } - if ( !sieve_validator_argument_activate(valdtr, cmd, *arg, FALSE) ) - return FALSE; - /* FIXME: We can currently only handle string literal argument, so * variables are not allowed. */ diff --git a/tests/compile/errors.svtest b/tests/compile/errors.svtest index b2c94ab95e7db0440cdb4360ec84276d24acb233..c2bc29251d745d10ab216073d2a3c1ecd06a66a8 100644 --- a/tests/compile/errors.svtest +++ b/tests/compile/errors.svtest @@ -242,6 +242,20 @@ test "Keep errors (FIXME: count only)" { } } +/* + * COMPARATOR errors + */ + +test "COMPARATOR errors (FIXME: count only)" { + if test_script_compile "errors/comparator.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "6" { + test_fail "wrong number of errors reported"; + } +} + /* * ADDRESS-PART errors */ diff --git a/tests/compile/errors/comparator.sieve b/tests/compile/errors/comparator.sieve new file mode 100644 index 0000000000000000000000000000000000000000..368b56bfcbd7e78692c741d88acce52e70aa0d55 --- /dev/null +++ b/tests/compile/errors/comparator.sieve @@ -0,0 +1,21 @@ +/* + * Address part errors + * + * Total errors: 5 (+1 = 6) + */ + +# 1: No argument +if address :comparator { } + +# 2: Number argument +if address :comparator 1 "from" "frop" { } + +# 3: String list argument +if address :comparator ["a", "b"] "from" "frop" { } + +# 4: Unknown tag +if address :comparator :frop "from" "frop" { } + +# 5: Known tag +if address :comparator :all "from" "frop" { } +