Synch to No Gnus 200602281432.
authoryamaoka <yamaoka>
Tue, 28 Feb 2006 14:43:19 +0000 (14:43 +0000)
committeryamaoka <yamaoka>
Tue, 28 Feb 2006 14:43:19 +0000 (14:43 +0000)
lisp/ChangeLog
lisp/spam.el

index fa2728a..597f827 100644 (file)
@@ -1,3 +1,13 @@
+2006-02-28  Reiner Steib  <Reiner.Steib@gmx.de>
+
+       * spam.el (spam-spamassassin-score-regexp): New internal variable.
+       (spam-extra-header-to-number, spam-check-spamassassin-headers):
+       Use it to match format of Spamassassin 3.0 and later.  Reported by
+       IRIE Tetsuya <irie@t.email.ne.jp>.
+       (spam-check-bogofilter)
+       (spam-bogofilter-register-with-bogofilter): Fix args of
+       `gnus-error' calls.
+
 2006-02-27  Reiner Steib  <Reiner.Steib@gmx.de>
 
        * gnus-sum.el (gnus-sequence-of-unread-articles): Return nil if
index 43b2d14..5c689bf 100644 (file)
@@ -1173,6 +1173,15 @@ backends)."
        (return))))
     result))
 
+(defvar spam-spamassassin-score-regexp
+  ".*\\b\\(?:score\\|hits\\)=\\(-?[0-9.]+\\)"
+  "Regexp matching SpamAssassin score header.
+The first group must match the number.")
+;; "score" for Spamassassin 3.0 or later:
+;; X-Spam-Status: Yes, score=13.1 required=5.0 tests=DNS_FROM_RFC_ABUSE,
+;;     [...],UNDISC_RECIPS autolearn=disabled version=3.0.3
+
+
 (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."
@@ -1181,7 +1190,8 @@ Note this has to be fast."
        ((eq header 'X-Spam-Status)
        (string-to-number (gnus-replace-in-string
                           (gnus-extra-header header headers)
-                          ".*hits=" "")))
+                          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))
@@ -2504,7 +2514,7 @@ REMOVE not nil, remove the ADDRESSES."
                     (if db `("-d" ,db "-v") `("-v"))))
            (setq return (spam-check-bogofilter-headers score))))
        return)
-    (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
+    (gnus-error 5 "`spam.el' doesn't support obsolete bogofilter versions")))
 
 (defun spam-bogofilter-register-with-bogofilter (articles
                                                 spam
@@ -2530,7 +2540,7 @@ REMOVE not nil, remove the ADDRESSES."
                     spam-bogofilter-path
                     nil nil nil switch
                     (if db `("-d" ,db "-v") `("-v")))))))
-    (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
+    (gnus-error 5 "`spam.el' doesn't support obsolete bogofilter versions")))
 
 (defun spam-bogofilter-register-spam-routine (articles &optional unregister)
   (spam-bogofilter-register-with-bogofilter articles t unregister))
@@ -2615,8 +2625,7 @@ REMOVE not nil, remove the ADDRESSES."
   (if score                            ; scoring mode
       (let ((header (message-fetch-field spam-spamassassin-spam-status-header)))
        (when header
-         (if (string-match "\\(?:score\\|hits\\)=\\(-?[0-9.]+\\)" header)
-             ;; "score" for Spamassassin 3.0 or later.
+         (if (string-match spam-spamassassin-score-regexp header)
              (match-string 1 header)
            "0")))
     ;; spam detection mode