Synch to No Gnus 200409281458.
authoryamaoka <yamaoka>
Tue, 28 Sep 2004 22:08:53 +0000 (22:08 +0000)
committeryamaoka <yamaoka>
Tue, 28 Sep 2004 22:08:53 +0000 (22:08 +0000)
lisp/ChangeLog
lisp/gnus-registry.el
lisp/gnus-util.el
lisp/hashcash.el
lisp/spam.el

index eefaeb5..d6e2f27 100644 (file)
@@ -1,3 +1,29 @@
+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)
index f0d955d..a770524 100644 (file)
@@ -371,7 +371,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
        references res)
     (if refstr
        (progn
-         (setq references (nreverse (gnus-split-references refstr)))
+         (setq references (nreverse (gnus-extract-references refstr)))
          (mapcar (lambda (x)
                    (setq res (or (gnus-registry-fetch-group x) res))
                    (when (or (gnus-registry-grep-in-list
index 89eff57..2be7de7 100644 (file)
@@ -488,6 +488,16 @@ inside loops."
            ids))
     (nreverse ids)))
 
+(defun gnus-extract-references (references)
+  "Return a list of Message-IDs in REFERENCES (in In-Reply-To
+  format), trimmed to only contain the Message-IDs."
+  (let ((ids (gnus-split-references references)) 
+       refs)
+    (dolist (id ids)
+      (when (string-match "<[^<>]+>" id)
+       (push (match-string 0 id) refs)))
+    refs))
+
 (defsubst gnus-parent-id (references &optional n)
   "Return the last Message-ID in REFERENCES.
 If N, return the Nth ancestor instead."
index 15383a0..b63bf16 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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
@@ -111,7 +111,8 @@ is used instead.")
 
 (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)
@@ -119,15 +120,20 @@ is used instead.")
                      "-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."
index d0e23df..690ad7f 100644 (file)
@@ -424,6 +424,8 @@ your main source of newsgroup names."
                 (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
@@ -966,7 +968,6 @@ backends)."
 (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)
 
@@ -2354,46 +2355,59 @@ REMOVE not nil, remove the ADDRESSES."
       (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))