[gnus git] branch master updated: m0-5-300-g756c16f =1= shr.el: Support <img src="data:...">

Katsumi Yamaoka <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  756c16f308caa87baa3654a5ae57d38f809f08c8 (commit)
      from  38e95dfb7571f7eff2ce74e62b1c2fb597143221 (commit)


- Log -----------------------------------------------------------------
commit 756c16f308caa87baa3654a5ae57d38f809f08c8
Author: David Edmondson <[email protected]>
Date:   Tue Apr 16 06:44:20 2013 +0000

    shr.el: Support <img src="data:...">

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0fb5ed5..bc6de1d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-16  David Edmondson  <[email protected]>
+
+	Support <img src="data:...">.
+
+	* shr.el (shr-image-from-data): New function.
+	(shr-tag-img) Use it.
+
 2013-04-14  Andrew Cohen  <[email protected]>
 
 	* nnir.el (nnir-request-set-mark): Make sure we are in the right
diff --git a/lisp/shr.el b/lisp/shr.el
index 5df5297..293ba24 100644
--- a/lisp/shr.el
+++ b/lisp/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)
@@ -983,6 +994,12 @@ ones, in case fg and bg are nil."
 	  ;; 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)))
 		image)

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    7 +++++++
 lisp/shr.el    |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.