Skip to content
Snippets Groups Projects
Commit 7b83caf1 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Added explicit messages and tests for unsupported use of variables.

parent 3a8746c9
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,8 @@ Next (in order of descending priority/precedence): ...@@ -42,7 +42,8 @@ Next (in order of descending priority/precedence):
* Make testsuite much more exhaustive and add support for testing the actual * Make testsuite much more exhaustive and add support for testing the actual
result. 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 * Build a server with test mail accounts that processes lots and lots of mail
(e.g. spam, mailing lists etc.) (e.g. spam, mailing lists etc.)
......
...@@ -176,11 +176,25 @@ static bool cmd_include_validate(struct sieve_validator *validator, ...@@ -176,11 +176,25 @@ static bool cmd_include_validate(struct sieve_validator *validator,
struct sieve_script *script; struct sieve_script *script;
const char *script_dir, *script_name; const char *script_dir, *script_name;
/* Check argument */
if ( !sieve_validate_positional_argument if ( !sieve_validate_positional_argument
(validator, cmd, arg, "value", 1, SAAT_STRING) ) { (validator, cmd, arg, "value", 1, SAAT_STRING) ) {
return FALSE; 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 */ /* Find the script */
script_name = sieve_ast_argument_strc(arg); script_name = sieve_ast_argument_strc(arg);
......
...@@ -116,10 +116,13 @@ static int mcht_regex_validate_key_argument ...@@ -116,10 +116,13 @@ static int mcht_regex_validate_key_argument
{ {
struct _regex_key_context *keyctx = (struct _regex_key_context *) context; 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) ) { if ( !sieve_argument_is_string_literal(key) ) {
sieve_argument_validate_error(keyctx->valdtr, key, sieve_argument_validate_error(keyctx->valdtr, key,
"this sieve implementation currently does not accept variable strings " "this Sieve implementation currently only accepts a literal string "
"as regular expression"); "for a regular expression");
return FALSE; return FALSE;
} }
......
...@@ -157,6 +157,19 @@ static bool tag_comparator_validate ...@@ -157,6 +157,19 @@ static bool tag_comparator_validate
sieve_ast_argument_name(*arg) ); sieve_ast_argument_name(*arg) );
return FALSE; 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 */ /* Get comparator from registry */
cmp = sieve_comparator_find(validator, sieve_ast_argument_strc(*arg)); cmp = sieve_comparator_find(validator, sieve_ast_argument_strc(*arg));
......
...@@ -313,3 +313,17 @@ test "Tagged argument errors (FIXME: count only)" { ...@@ -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";
}
}
/*
* 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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.