From a672b0a0b117c6790d1a6bac3dc91463ce5df2f0 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Tue, 28 Feb 2006 14:43:19 +0000 Subject: [PATCH] Synch to No Gnus 200602281432. --- lisp/ChangeLog | 10 ++++++++++ lisp/spam.el | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fa2728a..597f827 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2006-02-28 Reiner Steib + + * 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 . + (spam-check-bogofilter) + (spam-bogofilter-register-with-bogofilter): Fix args of + `gnus-error' calls. + 2006-02-27 Reiner Steib * gnus-sum.el (gnus-sequence-of-unread-articles): Return nil if diff --git a/lisp/spam.el b/lisp/spam.el index 43b2d14..5c689bf 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -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 -- 1.7.10.4