From 6a5b3818b2e8206843e2e5d7ad416ffe6ae3693f Mon Sep 17 00:00:00 2001 From: yamaoka Date: Wed, 31 Jul 2002 22:53:38 +0000 Subject: [PATCH] Synch with Oort Gnus. --- lisp/ChangeLog | 5 +++++ lisp/nnimap.el | 6 ++++-- lisp/spam.el | 66 +++++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 63bbdcb..f99fd7f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2002-07-31 Danny Siu + + * nnimap.el (nnimap-split-articles): do not call nnmail-fetch-field + when splitting malformed messages without message-id + 2002-07-28 Kai Gro,b_(Bjohann From Niklas Morberg . diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 99822b9..335cdcd 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -1219,8 +1219,10 @@ function is generally only called when Gnus is shutting down." (setq removeorig t) (when nnmail-cache-accepted-message-ids (with-current-buffer nntp-server-buffer - (nnmail-cache-insert (nnmail-fetch-field - "message-id") to-group))) + (let (msgid) + (and (setq msgid + (nnmail-fetch-field "message-id")) + (nnmail-cache-insert msgid to-group))))) ;; Add the group-art list to the history list. (push (list (cons to-group 0)) nnmail-split-history)) (t diff --git a/lisp/spam.el b/lisp/spam.el index 17f487f..9d42176 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -35,25 +35,29 @@ "relays.visi.com" "rbl.maps.vix.com") "List of blackhole servers.") +(defvar spam-split-group "spam" "Default group name for spam-split.") + (defun spam-check-blackholes () - "Check the Recevieved headers for blackholed relays." + "Check the Receieved headers for blackholed relays." (let ((headers (message-fetch-field "received")) ips matches) - (with-temp-buffer - (insert headers) - (goto-char (point-min)) - (while (re-search-forward - "\\[\\([0-9]+.[0-9]+.[0-9]+.[0-9]+\\)\\]" nil t) - (push (mapconcat 'identity - (nreverse (split-string (match-string 1) "\\.")) - ".") - ips))) - (dolist (server spam-blackhole-servers) - (dolist (ip ips) - (when (query-dns (concat ip "." server)) - (push (list ip server (query-dns (concat ip "." server) 'TXT)) - matches)))) - matches)) + (when headers + (with-temp-buffer + (insert headers) + (goto-char (point-min)) + (while (re-search-forward + "\\[\\([0-9]+.[0-9]+.[0-9]+.[0-9]+\\)\\]" nil t) + (message "blackhole search found host IP %s" (match-string 1)) + (push (mapconcat 'identity + (nreverse (split-string (match-string 1) "\\.")) + ".") + ips))) + (dolist (server spam-blackhole-servers) + (dolist (ip ips) + (when (query-dns (concat ip "." server)) + (push (list ip server (query-dns (concat ip "." server) 'TXT)) + matches)))) + matches))) ;;; Black- and white-lists @@ -87,7 +91,8 @@ Optional arg BLACKLIST, if non-nil, means to enter in the blacklist instead." (unless (bobp) (insert "\n")) (insert address "\n") - (save-buffer)))) + (save-buffer) + (spam-refresh-list-cache)))) (defun spam-enter-blacklist (address) "Enter ADDRESS into the blacklist." @@ -128,6 +133,33 @@ Optional arg BLACKLIST, if non-nil, means to enter in the blacklist instead." (setq found t))) found)) +(defun spam-address-blacklisted-p (address &optional blacklist) + (if address + (spam-address-whitelisted-p address t) + nil)) + +;; Function for nnmail-split-fancy: returns 'spam' if an article is deemed to be spam +(defun spam-split () + "Split this message into the `spam' group if it is spam. +This function can be used as an entry in `nnmail-split-fancy', for +example like this: (: spam-split) + +See the Info node `(gnus)Fancy Mail Splitting' for more details." + (interactive) + + ;; refresh the cache if it's necessary + (unless spam-whitelist-cache (spam-refresh-list-cache)) + (unless spam-blacklist-cache (spam-refresh-list-cache)) + + (let* ((from (message-fetch-field "from")) + (group nil)) + (when (spam-check-blackholes) + (setq group spam-split-group)) + (unless (spam-address-whitelisted-p from) ; unless the address is whitelisted, + (when (spam-address-blacklisted-p from) ; check if it's blacklisted, + (setq group spam-split-group)) ; and if so, set the group to spam-split-group + group))) + (provide 'spam) ;;; spam.el ends here -- 1.7.10.4