+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
(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."
((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))
(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
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))
(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