6.0.0-beta1
7/6/25

[#7308] Sieve: numeric comparison with negative numbers fails
Summary Sieve: numeric comparison with negative numbers fails
Queue Ingo
Queue Version 1.2
Type Enhancement
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester bb (at) apc (dot) ag
Created 09/09/2008 (6144 days ago)
Due
Updated 01/13/2010 (5653 days ago)
Assigned 09/18/2008 (6135 days ago)
Resolved 08/18/2009 (5801 days ago)
Milestone 1.2.2
Patch Yes

History
01/13/2010 12:10:39 AM CVS Commit Comment #9 Reply to this comment
Changes have been made in Git for this ticket:

MFB: Correctly match negative header values with numeric comparison in 
Sieve driver (bb@apc.ag, Bug #7308).

http://git.horde.org/diff.php/ingo/docs/CHANGES?rt=horde-git&r1=a50332ef341fa29c7acda0ed3e449a207ef0584d&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/lib/Script/Sieve.php?rt=horde-git&r1=9b22223f642b6ab65a71694ff34f709f06dfce9d&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/ca_ES/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/de_DE/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/en_US/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/es_ES/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/fi_FI/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/fr_FR/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
http://git.horde.org/diff.php/ingo/locale/lv_LV/help.xml?rt=horde-git&r1=34fde92a2cd38c530ede281396c13937d32f8554&r2=bade9b19e5062957438ae2935ef95cb653250b1a
08/18/2009 10:35:45 PM Jan Schneider Comment #8
State ⇒ Resolved
Milestone ⇒ 1.2.2
Reply to this comment
Tweaked and committed, thanks!
08/18/2009 10:05:58 PM Jan Schneider Deleted Original Message
 
09/18/2008 10:46:08 AM Jan Schneider Assigned to Jan Schneider
State ⇒ Assigned
 
09/12/2008 07:20:12 AM bb (at) tud (dot) at Comment #6
New Attachment: ingo-sieve-help-negative.patch Download
Reply to this comment
This is a patch adding a warning to the Ingo help for the English and 
German help.xml files
09/12/2008 06:38:31 AM bb (at) apc (dot) ag Comment #5
New Attachment: sieve-negative-v2.patch Download
Reply to this comment
OK, here is a new version of the patch, this time it's the Relational 
function that's changed. The change in the spam function was reverted 
because creating the Relational match has the same effect.



For comparisons <=, < and !=, the normal comparison is ORed with the 
check for the minus sign so negative numbers in the mail header match, 
too.



For comparisons >=, > and =, the minus sign in the mail header causes 
a non-match.



It's still not possible to use negative numbers for the comparison 
(i.e. enter them in Horde and hope that they'll work). But at least 
all cases of negative numbers in the mail header are supported as long 
as the entered comparison value is positive.
09/11/2008 01:55:48 PM Jan Schneider Comment #4 Reply to this comment
We can still check for negative values in the headers and ignore the 
rules in this case, like you do it now with the spam rule patch.
09/11/2008 01:47:08 PM bb (at) apc (dot) ag Comment #3 Reply to this comment
That's right. The problem is, as Sieve simply doesn't compare negative 
numbers correctly, there's no way to really fix it. If the header or 
comparison value are negative, the result is undefined.



See RFC (from January 2008): http://tools.ietf.org/html/rfc5231

It's the standard that says that the comparison doesn't support 
negative numbers, so probably this won't be fixed soon. Maybe Horde 
should display a warning when using the Sieve backend.



It works for the spam case because the reasonable range of 
X-Spam-Score is positive and we can assume that mails with a negative 
score won't be spam regardless of the score.
09/11/2008 12:31:18 PM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
The patch looks fine, but only takes care about the spam filter. If 
you made this work for the Relational test instead, all numeric 
comparisons would take advantage of the fix.
09/09/2008 09:11:58 AM bb (at) apc (dot) ag Comment #1
New Attachment: sieve-nonegative.patch
State ⇒ New
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Ingo
Summary ⇒ Sieve: numeric comparison with negative numbers fails
Type ⇒ Enhancement
Priority ⇒ 2. Medium
Reply to this comment
When using the Sieve backend in Ingo and setting numeric comparison of 
X-Spam-Score, Ingo generates a rule that compares the X-Spam-Score 
numerically with the entered value (e.g. 5). The problem is that this 
comparison fails with negative spam scores (which can be quite common) 
and the e-mail is moved into the spam folder. See, e.g.:

http://tomster.org/blog/archive/2004/12/15/spamfiltering-using-spamassassin-and-sieve



The rule will be correct if it checks for the minus sign.



Wrong:

if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" ["6"] {



Correct:

if allof ( not header :comparator "i;ascii-casemap" :contains 
"X-Spam-Score" "-", header :value "ge" :comparator "i;ascii-numeric" 
"X-Spam-Score" ["6"] ) {



Working patch attached.

Saved Queries