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 |
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
State ⇒ Resolved
Milestone ⇒ 1.2.2
http://cvs.horde.org/diff.php/ingo/docs/CHANGES?rt=horde&r1=1.55.2.122&r2=1.55.2.123&ty=u
http://cvs.horde.org/diff.php/ingo/lib/Script/sieve.php?rt=horde&r1=1.63.10.37&r2=1.63.10.38&ty=u
http://cvs.horde.org/diff.php/ingo/locale/ca_ES/help.xml?rt=horde&r1=1.1.2.2&r2=1.1.2.3&ty=u
http://cvs.horde.org/diff.php/ingo/locale/de_DE/help.xml?rt=horde&r1=1.1.4.3&r2=1.1.4.4&ty=u
http://cvs.horde.org/diff.php/ingo/locale/en_US/help.xml?rt=horde&r1=1.9.4.3&r2=1.9.4.4&ty=u
http://cvs.horde.org/diff.php/ingo/locale/es_ES/help.xml?rt=horde&r1=1.1.2.5&r2=1.1.2.6&ty=u
http://cvs.horde.org/diff.php/ingo/locale/eu_ES/help.xml?rt=horde&r1=1.1.2.1&r2=1.1.2.2&ty=u
http://cvs.horde.org/diff.php/ingo/locale/fi_FI/help.xml?rt=horde&r1=1.1.2.7&r2=1.1.2.8&ty=u
http://cvs.horde.org/diff.php/ingo/locale/fr_FR/help.xml?rt=horde&r1=1.1.2.2&r2=1.1.2.3&ty=u
http://cvs.horde.org/diff.php/ingo/locale/lv_LV/help.xml?rt=horde&r1=1.1.8.3&r2=1.1.8.4&ty=u
State ⇒ Assigned
New Attachment: ingo-sieve-help-negative.patch
German help.xml files
New Attachment: sieve-negative-v2.patch
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.
rules in this case, like you do it now with the spam rule patch.
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.
State ⇒ Feedback
you made this work for the Relational test instead, all numeric
comparisons would take advantage of the fix.
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
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.