From: David Edmondson Date: Tue, 16 Apr 2013 06:44:35 +0000 (+0000) Subject: lisp/gnus/shr.el: Support X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~450 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2250b3515720da23bc2cd12d597c1a75fac73d46;p=emacs.git lisp/gnus/shr.el: Support --- diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index cc7897accb6..f6cc590b026 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,10 @@ +2013-04-16 David Edmondson + + Support . + + * shr.el (shr-image-from-data): New function. + (shr-tag-img) Use it. + 2013-04-14 Andrew Cohen * nnir.el (nnir-request-set-mark): Make sure we are in the right diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 5df5297ba8a..293ba2445e9 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -593,6 +593,17 @@ size, and full-buffer size." (put-text-property start (point) type value)))))))))) (kill-buffer image-buffer))) +(defun shr-image-from-data (data) + "Return an image from the data: URI content DATA." + (when (string-match + "\\(\\([^/;,]+\\(/[^;,]+\\)?\\)\\(;[^;,]+\\)*\\)?,\\(.*\\)" + data) + (let ((param (match-string 4 data)) + (payload (url-unhex-string (match-string 5 data)))) + (when (string-match "^.*\\(;[ \t]*base64\\)$" param) + (setq payload (base64-decode-string payload))) + payload))) + (defun shr-put-image (data alt &optional flags) "Put image DATA with a string ALT. Return image." (if (display-graphic-p) @@ -982,6 +993,12 @@ ones, in case fg and bg are nil." (member (cdr (assq :width cont)) '("0" "1"))) ;; Ignore zero-sized or single-pixel images. ) + ((and (not shr-inhibit-images) + (string-match "\\`data:" url)) + (let ((image (shr-image-from-data (substring url (match-end 0))))) + (if image + (funcall shr-put-image-function image alt) + (insert alt)))) ((and (not shr-inhibit-images) (string-match "\\`cid:" url)) (let ((url (substring url (match-end 0)))