From b4ebfceab57568e28f7a55358be6e4cc84c9e6a1 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Tue, 31 Aug 2010 17:06:34 +0200 Subject: [PATCH] Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable. --- lisp/ChangeLog | 2 ++ lisp/gnus-html.el | 47 ++++++++++++++++++++++++++--------------------- texi/ChangeLog | 6 ++++-- texi/gnus.texi | 12 ++++++++++++ 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0b4b03f43..32657975e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2010-08-31 Lars Magne Ingebrigtsen + * gnus-html.el (gnus-blocked-images): New variable. + * message.el (message-prune-recipients): New function. (message-prune-recipient-rules): New variable. diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el index cf0299e7a..7a330165b 100644 --- a/lisp/gnus-html.el +++ b/lisp/gnus-html.el @@ -45,6 +45,11 @@ :group 'gnus-art :type 'integer) +(defcustom gnus-blocked-images "." + "Images that have URLs matching this regexp will be blocked." + :group 'gnus-art + :type 'regexp) + ;;;###autoload (defun gnus-article-html (handle) (let ((article-buffer (current-buffer))) @@ -90,23 +95,23 @@ ((equal tag "img_alt") (when (string-match "src=\"\\([^\"]+\\)" parameters) (setq url (match-string 1 parameters)) - (when (or (null mm-w3m-safe-url-regexp) - (string-match mm-w3m-safe-url-regexp url)) - (if (string-match "^cid:\\(.*\\)" url) - ;; URLs with cid: have their content stashed in other - ;; parts of the MIME structure, so just insert them - ;; immediately. - (let ((handle (mm-get-content-id - (setq url (match-string 1 url)))) - image) - (when handle - (mm-with-part handle - (setq image (gnus-create-image (buffer-string) - nil t)))) - (when image - (delete-region start end) - (gnus-put-image image))) - ;; Normal, external URL. + (if (string-match "^cid:\\(.*\\)" url) + ;; URLs with cid: have their content stashed in other + ;; parts of the MIME structure, so just insert them + ;; immediately. + (let ((handle (mm-get-content-id + (setq url (match-string 1 url)))) + image) + (when handle + (mm-with-part handle + (setq image (gnus-create-image (buffer-string) + nil t)))) + (when image + (delete-region start end) + (gnus-put-image image))) + ;; Normal, external URL. + (when (or (null gnus-blocked-images) + (not (string-match gnus-blocked-images url))) (let ((file (gnus-html-image-id url))) (if (file-exists-p file) ;; It's already cached, so just insert it. @@ -221,16 +226,16 @@ ;;;###autoload (defun gnus-html-prefetch-images (summary) - (let (safe-url-regexp urls) + (let (blocked-images urls) (when (buffer-live-p summary) (save-excursion (set-buffer summary) - (setq safe-url-regexp mm-w3m-safe-url-regexp)) + (setq blocked-images gnus-blocked-images)) (save-match-data (while (re-search-forward " - * message.texi (Wide Reply): Document message-prune-recipient-rules. + * gnus.texi (HTML): Document gnus-blocked-images. + + * message.texi (Wide Reply): Document message-prune-recipient-rules. 2010-08-30 Lars Magne Ingebrigtsen @@ -21,7 +23,7 @@ 2010-08-29 Lars Magne Ingebrigtsen * gnus.texi (Asynchronous Fetching): Document - gnus-async-post-fetch-function. + gnus-async-post-fetch-function. (HTML): Made into its own section. 2010-06-24 Glenn Morris diff --git a/texi/gnus.texi b/texi/gnus.texi index 913743e0c..5bbbbde4c 100644 --- a/texi/gnus.texi +++ b/texi/gnus.texi @@ -12501,6 +12501,18 @@ section only describes the default method. If set to @code{gnus-article-html}, Gnus will use the built-in method, that's based on @code{curl} and @code{w3m}. +@item gnus-blocked-images +@vindex gnus-blocked-images +Images that have @acronym{URL}s that match this regexp won't be +fetched and displayed. For instance, do block all @acronym{URL}s that +have the string ``ads'' in them, do the following: + +@lisp +(setq gnus-blocked-images "ads") +@end lisp + +The default is to block all external images. + @item gnus-html-cache-directory @vindex gnus-html-cache-directory Gnus will download and cache images according to how -- 2.34.1