diff --git a/TODO b/TODO index 6d870526584bbc4153abeaaddb8254323b1b0f1e..756f208338390fbe69c64db5b228911f8e666b36 100644 --- a/TODO +++ b/TODO @@ -42,7 +42,8 @@ Next (in order of descending priority/precedence): * Make testsuite much more exhaustive and add support for testing the actual result. -* Build a sieve tool to filter an entire existing mailbox through a sieve script. +* Build a sieve tool to filter an entire existing mailbox through a sieve + script. * Build a server with test mail accounts that processes lots and lots of mail (e.g. spam, mailing lists etc.) diff --git a/src/lib-sieve/plugins/include/cmd-include.c b/src/lib-sieve/plugins/include/cmd-include.c index ca1a329e2997953a3c80dcaf10ba2168114f27c7..426fdc556b24d6533b840a7a4541bd7a8b8d05b0 100644 --- a/src/lib-sieve/plugins/include/cmd-include.c +++ b/src/lib-sieve/plugins/include/cmd-include.c @@ -176,11 +176,25 @@ static bool cmd_include_validate(struct sieve_validator *validator, struct sieve_script *script; const char *script_dir, *script_name; + /* Check argument */ if ( !sieve_validate_positional_argument (validator, cmd, arg, "value", 1, SAAT_STRING) ) { return FALSE; } + if ( !sieve_validator_argument_activate(validator, cmd, arg, FALSE) ) + return FALSE; + + /* FIXME: We can currently only handle string literal argument, so + * variables are not allowed. + */ + if ( !sieve_argument_is_string_literal(arg) ) { + sieve_argument_validate_error(validator, arg, + "this Sieve implementation currently only supports " + "a literal string argument for the include command"); + return FALSE; + } + /* Find the script */ script_name = sieve_ast_argument_strc(arg); diff --git a/src/lib-sieve/plugins/regex/mcht-regex.c b/src/lib-sieve/plugins/regex/mcht-regex.c index 77536621db0044fe97433fbc315e1d0643be24a6..26be8f668ed11c6281aa1993ea1f0c55b3fa2eb1 100644 --- a/src/lib-sieve/plugins/regex/mcht-regex.c +++ b/src/lib-sieve/plugins/regex/mcht-regex.c @@ -116,10 +116,13 @@ static int mcht_regex_validate_key_argument { struct _regex_key_context *keyctx = (struct _regex_key_context *) context; + /* FIXME: We can currently only handle string literal argument, so + * variables are not allowed. + */ if ( !sieve_argument_is_string_literal(key) ) { sieve_argument_validate_error(keyctx->valdtr, key, - "this sieve implementation currently does not accept variable strings " - "as regular expression"); + "this Sieve implementation currently only accepts a literal string " + "for a regular expression"); return FALSE; } diff --git a/src/lib-sieve/sieve-comparators.c b/src/lib-sieve/sieve-comparators.c index 038f858928ca63cecb5c8f860dd993a049fc7b99..f6be3e5502b570e0d259d028cbffee2c7f273247 100644 --- a/src/lib-sieve/sieve-comparators.c +++ b/src/lib-sieve/sieve-comparators.c @@ -157,6 +157,19 @@ static bool tag_comparator_validate sieve_ast_argument_name(*arg) ); return FALSE; } + + if ( !sieve_validator_argument_activate(validator, cmd, *arg, FALSE) ) + return FALSE; + + /* FIXME: We can currently only handle string literal argument, so + * variables are not allowed. + */ + if ( !sieve_argument_is_string_literal(*arg) ) { + sieve_argument_validate_error(validator, *arg, + "this Sieve implementation currently only supports " + "a literal string argument for the :comparator tag"); + return FALSE; + } /* Get comparator from registry */ cmp = sieve_comparator_find(validator, sieve_ast_argument_strc(*arg)); diff --git a/tests/compile/errors.svtest b/tests/compile/errors.svtest index 024b41f20b99c99b154549d1bca2b3980c10a41a..98430a163dc36f49d9cff28561f77d1e6a9c093f 100644 --- a/tests/compile/errors.svtest +++ b/tests/compile/errors.svtest @@ -313,3 +313,17 @@ test "Tagged argument errors (FIXME: count only)" { } } +/* + * Unsupported language features + */ + +test "Unsupported language features (FIXME: count only)" { + if test_compile "errors/unsupported.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "4" { + test_fail "wrong number of errors reported"; + } +} + diff --git a/tests/compile/errors/unsupported.sieve b/tests/compile/errors/unsupported.sieve new file mode 100644 index 0000000000000000000000000000000000000000..6ecf21d0741fa46ababc3bf5976009a4a792c4db --- /dev/null +++ b/tests/compile/errors/unsupported.sieve @@ -0,0 +1,39 @@ +/* + * Handling of unsupported language features. + * + * Total errors: 3 (+1 = 4) + */ + +require "variables"; +require "include"; +require "regex"; + +/* + * Unsupported use of variables + */ + +/* Comparator argument */ + +set "comp" "i;ascii-numeric"; + +if address :comparator "${comp}" "from" "stephan@rename-it.nl" { + stop; +} + +/* Included script */ + +set "script" "blacklist"; + +include "${blacklist}"; + +/* Variable regexp */ + +set "match" "(.*)rename-it(.*)"; + +if address :regex "from" "${match}" { + stop; +} + + + +