1 ;;; spam-wash.el --- wash spam before analysis
3 ;; Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
5 ;; Author: Andrew Cohen <cohen@andy.bu.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; This library decodes MIME encodings such as base64 and
26 ;; quoted-printable to allow for better spam analysis.
28 ;; `spam-wash' should be called in a buffer containing the message.
35 "Treat the current buffer prior to spam analysis."
37 (run-hooks 'gnus-article-decode-hook
)
40 (let* ((buffer-read-only nil
)
41 (gnus-inhibit-treatment t
)
42 (gnus-article-buffer (current-buffer))
43 (handles (or (mm-dissect-buffer nil gnus-article-loose-mime
)
44 (and gnus-article-emulate-mime
47 (when gnus-article-mime-handles
48 (mm-destroy-parts gnus-article-mime-handles
)
49 (setq gnus-article-mime-handle-alist nil
))
50 (setq gnus-article-mime-handles handles
)
52 (or (not (stringp (car handles
)))
55 (delete-region (point) (point-max))
56 (spam-treat-parts handles
))))))
58 (defun spam-treat-parts (handle)
59 (if (stringp (car handle
))
60 (mapcar 'spam-treat-parts
(cdr handle
))
61 (if (bufferp (car handle
))
63 (narrow-to-region (point) (point))
64 (when (let ((case-fold-search t
))
65 (string-match "text" (car (mm-handle-type handle
))))
66 (mm-insert-part handle
))
67 (goto-char (point-max)))
68 (mapcar 'spam-treat-parts handle
))))
72 ;; arch-tag: 3c7f94a7-c96d-4c77-bb59-950df12bc85f
73 ;;; spam-wash.el ends here