Gnus development mailing list
 help / color / mirror / Atom feed
* [spam.el] Problem with obtaining the spam score for CRM114
@ 2006-04-15 11:59 João Cachopo
  2006-04-15 23:45 ` Miles Bader
  2006-04-16 16:31 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: João Cachopo @ 2006-04-15 11:59 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 768 bytes --]


Hi!

I switched recently from bogofilter to CRM114 and when I tried to sort
the summary of my spam group by the article spam score assigned by
CRM114, I couldn't made it to work.  The spam score of every article
showed up as 0.00 in the summary buffer.

One of the problems seems to be that the spam-necessary-extra-headers
function on spam.el only deals with SpamAssassin and Bogofilter.  I
guess that the header added by the CRM114 filter should be added to
the list of extra headers, also.

Once that is fixed, there remains another problem in the
spam-extra-header-to-number function, which already extracts the
proper score from the CRM114 header, but returns a string instead of a
number.

I include below a patch against spam.el that fixes both these errors.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: spam.patch --]
[-- Type: text/x-patch, Size: 2163 bytes --]

--- spam.el.orig	2006-03-28 20:51:41.000000000 +0100
+++ spam.el	2006-04-15 12:33:48.000000000 +0100
@@ -1156,6 +1156,8 @@
       (push 'X-Spam-Status list))
     (when spam-use-bogofilter
       (push 'X-Bogosity list))
+    (when spam-use-crm114
+      (push 'X-CRM114-Status list))
     list))
 
 (defun spam-user-format-function-S (headers)
@@ -1186,24 +1188,25 @@
 (defun spam-extra-header-to-number (header headers)
   "Transform an extra HEADER to a number, using list of HEADERS.
 Note this has to be fast."
-  (if (gnus-extra-header header headers)
-      (cond
-       ((eq header 'X-Spam-Status)
-	(string-to-number (gnus-replace-in-string
-			   (gnus-extra-header header headers)
-			   spam-spamassassin-score-regexp
-			   "\\1")))
-       ;; for CRM checking, it's probably faster to just do the string match
-       ((and spam-use-crm114 (string-match "( pR: \\([0-9.-]+\\)" header))
-	(match-string 1 header))
-       ((eq header 'X-Bogosity)
-	(string-to-number (gnus-replace-in-string
-			   (gnus-replace-in-string
-			    (gnus-extra-header header headers)
-			    ".*spamicity=" "")
-			   ",.*" "")))
-       (t nil))
-    nil))
+  (let ((header-content (gnus-extra-header header headers)))
+    (if header-content
+        (cond
+         ((eq header 'X-Spam-Status)
+          (string-to-number (gnus-replace-in-string
+                             header-content
+                             spam-spamassassin-score-regexp
+                             "\\1")))
+         ;; for CRM checking, it's probably faster to just do the string match
+         ((and spam-use-crm114 (string-match "( pR: \\([0-9.-]+\\)" header-content))
+          (string-to-number (match-string 1 header-content)))
+         ((eq header 'X-Bogosity)
+          (string-to-number (gnus-replace-in-string
+                             (gnus-replace-in-string
+                              header-content
+                              ".*spamicity=" "")
+                             ",.*" "")))
+         (t nil))
+      nil)))
 
 (defun spam-summary-score (headers &optional specific-header)
   "Score an article for the summary buffer, as fast as possible.

[-- Attachment #3: Type: text/plain, Size: 31 bytes --]


Best regards,
--
João Cachopo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-18 20:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-15 11:59 [spam.el] Problem with obtaining the spam score for CRM114 João Cachopo
2006-04-15 23:45 ` Miles Bader
2006-04-17  9:09   ` João Cachopo
2006-04-18 20:27     ` Ted Zlatanov
2006-04-16 16:31 ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).