From f8d8a97bda1c83380f3f688c4ba0b7fa16320c83 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Wed, 17 Nov 2010 08:28:15 +0000 Subject: [PATCH] shr.el (shr-image-displayer): Protect function against non-existent image source. --- lisp/gnus/ChangeLog | 3 +++ lisp/gnus/shr.el | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 7d3b2d06835..b509bc39c76 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,5 +1,8 @@ 2010-11-17 Katsumi Yamaoka + * shr.el (shr-image-displayer): Protect function against non-existent + image source. + * gnus-art.el (gnus-inhibit-images): New user option. (gnus-mime-display-single): Don't display image if it is non-nil. diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 2dd33ecbc13..526f8121891 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -441,19 +441,20 @@ CONTENT-FUNCTION is a function to retrieve an image for a cid url that is an argument. The function to be returned takes three arguments URL, START, and END." `(lambda (url start end) - (if (string-match "\\`cid:" url) - ,(when content-function - `(let ((image (funcall ,content-function - (substring url (match-end 0))))) - (when image - (goto-char start) - (shr-put-image image - (prog1 - (buffer-substring-no-properties start end) - (delete-region start end)))))) - (url-retrieve url 'shr-image-fetched - (list (current-buffer) start end) - t)))) + (when url + (if (string-match "\\`cid:" url) + ,(when content-function + `(let ((image (funcall ,content-function + (substring url (match-end 0))))) + (when image + (goto-char start) + (shr-put-image image + (prog1 + (buffer-substring-no-properties start end) + (delete-region start end)))))) + (url-retrieve url 'shr-image-fetched + (list (current-buffer) start end) + t))))) (defun shr-heading (cont &rest types) (shr-ensure-paragraph) -- 2.39.5