emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112305: lisp/gnus/shr.el: Support <i


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112305: lisp/gnus/shr.el: Support <img src="data:...">
Date: Tue, 16 Apr 2013 06:44:35 +0000
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112305
author: David Edmondson <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Tue 2013-04-16 06:44:35 +0000
message:
  lisp/gnus/shr.el: Support <img src="data:...">
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/shr.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2013-04-14 22:16:44 +0000
+++ b/lisp/gnus/ChangeLog       2013-04-16 06:44:35 +0000
@@ -1,3 +1,10 @@
+2013-04-16  David Edmondson  <address@hidden>
+
+       Support <img src="data:...">.
+
+       * shr.el (shr-image-from-data): New function.
+       (shr-tag-img) Use it.
+
 2013-04-14  Andrew Cohen  <address@hidden>
 
        * nnir.el (nnir-request-set-mark): Make sure we are in the right

=== modified file 'lisp/gnus/shr.el'
--- a/lisp/gnus/shr.el  2013-03-05 17:13:01 +0000
+++ b/lisp/gnus/shr.el  2013-04-16 06:44:35 +0000
@@ -593,6 +593,17 @@
                      (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 @@
          ;; 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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]