+2004-09-28 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * spam.el (spam-verify-bogofilter): new function
+ (spam-check-bogofilter)
+ (spam-bogofilter-register-with-bogofilter): use it
+ (spam-verify-bogofilter): small fixes
+
+2004-09-28 Simon Josefsson <jas@extundo.com>
+
+ * hashcash.el (hashcash-generate-payment): Revert.
+
+2004-09-28 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * gnus-registry.el (gnus-registry-split-fancy-with-parent): use
+ gnus-extract-references instead of gnus-split-references
+
+ * gnus-util.el (gnus-extract-references): new function, analogous
+ to gnus-split-references but extracts only the message-ID without
+ anything extra
+
+ * hashcash.el (hashcash-generate-payment)
+ (hashcash-check-payment): do the right thing if hashcash-path is
+ nil (because the hashcash program could not be found)
+
+ * spam.el (spam-use-hashcash): remove comment
+
2004-09-27 Jesper Harder <harder@ifa.au.dk>
* gnus-cache.el (gnus-cache-possibly-remove-articles-1)
;;; hashcash.el --- Add hashcash payments to email
+;; Copyright (C) 2003, 2004 Free Software Foundation
;; Copyright (C) 1997--2002 Paul E. Foley
-;; Copyright (C) 2003 Free Software Foundation
;; Maintainer: Paul Foley <mycroft@actrix.gen.nz>
;; Keywords: mail, hashcash
(defun hashcash-generate-payment (str val)
"Generate a hashcash payment by finding a VAL-bit collison on STR."
- (if (> val 0)
+ (if (and (> val 0)
+ hashcash-path)
(save-excursion
(set-buffer (get-buffer-create " *hashcash*"))
(erase-buffer)
"-m" "-q" "-b" (number-to-string val) str)
(goto-char (point-min))
(hashcash-token-substring))
- nil))
+ (error "No `hashcash' binary found")))
(defun hashcash-check-payment (token str val)
"Check the validity of a hashcash payment."
- (zerop (call-process hashcash-path nil nil nil "-c"
- "-d" "-f" hashcash-double-spend-database
- "-b" (number-to-string val)
- "-r" str
- token)))
+ (if hashcash-path
+ (zerop (call-process hashcash-path nil nil nil "-c"
+ "-d" "-f" hashcash-double-spend-database
+ "-b" (number-to-string val)
+ "-r" str
+ token))
+ (progn
+ (message "No hashcash binary found")
+ (sleep-for 1)
+ nil)))
(defun hashcash-version (token)
"Find the format version of a hashcash token."
(const :tag "Bogofilter is not installed"))
:group 'spam-bogofilter)
+(defvar spam-bogofilter-valid 'unknown "Is the bogofilter version valid?")
+
(defcustom spam-bogofilter-header "X-Bogosity"
"The header that Bogofilter inserts in messages."
:type 'string
(spam-install-checkonly-backend 'spam-use-blackholes
'spam-check-blackholes)
-;; TODO: does anyone use hashcash? We should remove it if not.
(spam-install-checkonly-backend 'spam-use-hashcash
'spam-check-hashcash)
(message "Spamicity score %s" score)
(or score "0"))))
+(defun spam-verify-bogofilter ()
+ "Verify the Bogofilter version is sufficient."
+ (when (eq spam-bogofilter-valid 'never)
+ (setq spam-bogofilter-valid
+ (not (string-match "^bogofilter version 0\\.\\([0-9]\\|1[01]\\)\\."
+ (shell-command-to-string
+ (format "%s -sV" spam-bogofilter-path))))))
+ spam-bogofilter-valid)
+
(defun spam-check-bogofilter (&optional score)
- "Check the Bogofilter backend for the classification of this message"
- (let ((article-buffer-name (buffer-name))
- (db spam-bogofilter-database-directory)
+ "Check the Bogofilter backend for the classification of this message."
+ (if (spam-verify-bogofilter)
+ (let ((article-buffer-name (buffer-name))
+ (db spam-bogofilter-database-directory)
+ return)
+ (with-temp-buffer
+ (let ((temp-buffer-name (buffer-name)))
+ (save-excursion
+ (set-buffer article-buffer-name)
+ (apply 'call-process-region
+ (point-min) (point-max)
+ spam-bogofilter-path
+ nil temp-buffer-name nil
+ (if db `("-d" ,db "-v") `("-v"))))
+ (setq return (spam-check-bogofilter-headers score))))
return)
- (with-temp-buffer
- (let ((temp-buffer-name (buffer-name)))
- (save-excursion
- (set-buffer article-buffer-name)
- (apply 'call-process-region
- (point-min) (point-max)
- spam-bogofilter-path
- nil temp-buffer-name nil
- (if db `("-d" ,db "-v") `("-v"))))
- (setq return (spam-check-bogofilter-headers score))))
- return))
+ (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
(defun spam-bogofilter-register-with-bogofilter (articles
spam
&optional unregister)
"Register an article, given as a string, as spam or non-spam."
- (dolist (article articles)
- (let ((article-string (spam-get-article-as-string article))
- (db spam-bogofilter-database-directory)
- (switch (if unregister
- (if spam
- spam-bogofilter-spam-strong-switch
- spam-bogofilter-ham-strong-switch)
- (if spam
- spam-bogofilter-spam-switch
- spam-bogofilter-ham-switch))))
- (when (stringp article-string)
- (with-temp-buffer
- (insert article-string)
-
- (apply 'call-process-region
- (point-min) (point-max)
- spam-bogofilter-path
- nil nil nil switch
- (if db `("-d" ,db "-v") `("-v"))))))))
+ (if (spam-verify-bogofilter)
+ (dolist (article articles)
+ (let ((article-string (spam-get-article-as-string article))
+ (db spam-bogofilter-database-directory)
+ (switch (if unregister
+ (if spam
+ spam-bogofilter-spam-strong-switch
+ spam-bogofilter-ham-strong-switch)
+ (if spam
+ spam-bogofilter-spam-switch
+ spam-bogofilter-ham-switch))))
+ (when (stringp article-string)
+ (with-temp-buffer
+ (insert article-string)
+
+ (apply 'call-process-region
+ (point-min) (point-max)
+ spam-bogofilter-path
+ nil nil nil switch
+ (if db `("-d" ,db "-v") `("-v")))))))
+ (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
(defun spam-bogofilter-register-spam-routine (articles &optional unregister)
(spam-bogofilter-register-with-bogofilter articles t unregister))