Hi Stephan,
I noticed that you changed i;ascii-numeric comparator recently
(<http://hg.rename-it.nl/dovecot-1.2-sieve/rev/17fb38aee85f>) to correct a
small bug. I have an interest in this because I use the comparator to
check for SpamAssassin scores. Before the fix, this was all that was
necessary to check for scores above a certain value:
header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "5"
Since SpamAssassin includes negative scores and the i;ascii-numeric
comparator doesn't recognize negative numbers, all negative scores are
actually treated as positive infinity after the fix. Of course, this
means mail which has a negative score then gets counted as spam.
Now an additional test is necessary, something like this:
allof(not header :matches "X-Spam-Score" "-*",
header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "5")
I thought I'd mention this because other people may get affected by this
once 0.1.15 comes out.
Here is a patch that makes further tests for the comparator between
numeric and non-numeric values. Hope you can use it.
-=- julian
# HG changeset patch
# User Julian Cowley <[email protected]>
# Date 1264074447 36000
# Node ID db2b3626e180eab12434914d26ede4d5de65fed1
# Parent 77fcb66823bf58949c7ba62e2b8b5f2751fa5816
Added tests for i;ascii-numeric comparator between numeric and non-numeric.
This tests that a non-numeric is always counted as positive infinity.
diff --git a/tests/extensions/relational/comparators.svtest b/tests/extensions/relational/comparators.svtest
--- a/tests/extensions/relational/comparators.svtest
+++ b/tests/extensions/relational/comparators.svtest
@@ -132,6 +132,54 @@
test_fail "not 'b' eq 'a'";
}
+ if string :comparator "i;ascii-numeric" :value "eq" "a" "0" {
+ test_fail "'a' eq '0'";
+ }
+
+ if string :comparator "i;ascii-numeric" :value "eq" "0" "a" {
+ test_fail "'0' eq 'a'";
+ }
+
+ if string :comparator "i;ascii-numeric" :value "lt" "a" "0" {
+ test_fail "'a' lt '0'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "lt" "0" "a" {
+ test_fail "not '0' lt 'a'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "gt" "a" "0" {
+ test_fail "not 'a' gt '0'";
+ }
+
+ if string :comparator "i;ascii-numeric" :value "gt" "0" "a" {
+ test_fail "'0' gt 'a'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "ne" "a" "0" {
+ test_fail "not 'a' ne '0'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "ne" "0" "a" {
+ test_fail "not '0' ne 'a'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "ge" "a" "0" {
+ test_fail "not 'a' ge '0'";
+ }
+
+ if string :comparator "i;ascii-numeric" :value "ge" "0" "a" {
+ test_fail "'0' ge 'a'";
+ }
+
+ if string :comparator "i;ascii-numeric" :value "le" "a" "0" {
+ test_fail "'a' le '0'";
+ }
+
+ if not string :comparator "i;ascii-numeric" :value "le" "0" "a" {
+ test_fail "not '0' le 'a'";
+ }
+
if not string :comparator "i;ascii-numeric" :value "eq" "0" "0" {
test_fail "not '0' eq '0'";
}