diff --git a/Makefile.am b/Makefile.am index 41e6907bed98401af7d2ebae523ab2638756af44..59d1fb8d39712f7062235080a1a166472aede4b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,6 +118,7 @@ test_cases = \ tests/extensions/spamvirustest/spamtest.svtest \ tests/extensions/spamvirustest/virustest.svtest \ tests/extensions/spamvirustest/spamtestplus.svtest \ + tests/extensions/spamvirustest/errors.svtest \ $(test_unfinished) $(test_cases): diff --git a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c index 2b61a20072b1142419c68af3b30edc11acea2d7d..35bc33aa4e907147ac1d779ca020affa50203d22 100644 --- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c +++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c @@ -133,6 +133,7 @@ static bool ext_spamvirustest_header_spec_parse return FALSE; } p++; + while ( *p == ' ' || *p == '\t' ) p++; spec->regexp_match = TRUE; if ( !_regexp_compile(&spec->regexp, p, ®exp_error) ) { diff --git a/tests/extensions/spamvirustest/errors.svtest b/tests/extensions/spamvirustest/errors.svtest new file mode 100644 index 0000000000000000000000000000000000000000..7e6b794b3dbe2efec92fd092447f390dfdd6812e --- /dev/null +++ b/tests/extensions/spamvirustest/errors.svtest @@ -0,0 +1,15 @@ +require "vnd.dovecot.testsuite"; + +require "comparator-i;ascii-numeric"; +require "relational"; + +test "Syntax errors" { + if test_script_compile "errors/syntax-errors.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "5" { + test_fail "wrong number of errors reported"; + } +} + diff --git a/tests/extensions/spamvirustest/errors/syntax-errors.sieve b/tests/extensions/spamvirustest/errors/syntax-errors.sieve new file mode 100644 index 0000000000000000000000000000000000000000..82e49ed58eb2d7357eddbbd84aabc2ce1f119787 --- /dev/null +++ b/tests/extensions/spamvirustest/errors/syntax-errors.sieve @@ -0,0 +1,19 @@ +require "spamtest"; +require "virustest"; + +# Value not a string +if spamtest 3 { +} + +# Value not a string +if virustest 3 { +} + +# Missing value argument +if spamtest :matches :comparator "i;ascii-casemap" { +} + +# Inappropriate :percent argument +if spamtest :percent "3" { +} + diff --git a/tests/extensions/spamvirustest/spamtest.svtest b/tests/extensions/spamvirustest/spamtest.svtest index 917a5cce7c24a026ab0718670ec852fee2ea0ed4..b032d6a695c7c4b51ca21e3da0b35f8e677cbb30 100644 --- a/tests/extensions/spamvirustest/spamtest.svtest +++ b/tests/extensions/spamvirustest/spamtest.svtest @@ -84,7 +84,7 @@ test "Value: low" { } test_config :set "sieve_spamtest_status_header" - "X-SpamCheck3:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)"; + "X-SpamCheck3: [ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)"; test_config :reload "spamtest"; test "Value: high" {